CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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
23 // DQM Framework
28 // Geometry
34 // DataFormats
42 //
43 #include <string>
44 #include <stdlib.h>
45 
46 using namespace std;
47 using namespace edm;
48 
50  conf_(iConfig),
51  rawin_( consumes<FEDRawDataCollection>( conf_.getParameter<edm::InputTag>( "RawInput" ) ) ),
52  errin_( consumes<edm::DetSetVector<SiPixelRawDataError> >( conf_.getParameter<edm::InputTag>( "ErrorInput" ) ) ),
53  saveFile( conf_.getUntrackedParameter<bool>("saveFile",false) ),
54  slowDown( conf_.getUntrackedParameter<bool>("slowDown",false) ),
55  dirName_( conf_.getUntrackedParameter<string>("DirName","Pixel/FEDIntegrity/") )
56 {
57  firstRun = true;
58  LogInfo ("PixelDQM") << "SiPixelHLTSource::SiPixelHLTSource: Got DQM BackEnd interface"<<endl;
59 }
60 
61 
63 {
64  // do anything here that needs to be done at desctruction time
65  // (e.g. close files, deallocate resources etc.)
66  LogInfo ("PixelDQM") << "SiPixelHLTSource::~SiPixelHLTSource: Destructor"<<endl;
67 }
68 
69 
71  LogInfo ("PixelDQM") << " SiPixelHLTSource::beginJob - Initialisation ... " << std::endl;
72  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
73  if(firstRun){
74  eventNo = 0;
75 
76  firstRun = false;
77  }
78 }
79 
81  // Book Monitoring Elements
82  bookMEs(iBooker);
83 }
84 
85 //------------------------------------------------------------------
86 // Method called for every event
87 //------------------------------------------------------------------
89 {
90  eventNo++;
91  // get raw input data
93  iEvent.getByToken( rawin_, rawinput );
94  // get error input data
96  iEvent.getByToken( errin_, errorinput );
97  if (!errorinput.isValid()) return;
98 
99  int fedId;
100 
101  for(fedId = 0; fedId <= 39; fedId++) {
102  //get event data for this fed
103  const FEDRawData& fedRawData = rawinput->FEDData( fedId );
104  if (fedRawData.size() != 0) (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) : (meNErrors_)->Fill(fedId); break;
119  case(36) : (meNErrors_)->Fill(fedId); break;
120  case(37) : (meNErrors_)->Fill(fedId); break;
121  case(38) : (meNErrors_)->Fill(fedId); break;
122  default : break;
123  }; // end switch
124  } // end for(di
125  } // end if( isearch
126  } // end if( ((*it)->subDetector()
127  } // for(TrackerGeometry
128 
129  edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = errorinput->find(0xffffffff);
130 
131  if( isearch != errorinput->end() ) { // Not at empty iterator
132  for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
133  fedId = di->getFedId(); // FED the error came from
134  int errorType = di->getType(); // type of error
135  switch(errorType) {
136  case(35) : (meNErrors_)->Fill(fedId); break;
137  case(36) : (meNErrors_)->Fill(fedId); break;
138  case(37) : (meNErrors_)->Fill(fedId); break;
139  case(38) : (meNErrors_)->Fill(fedId); break;
140  case(39) : (meNCRCs_)->Fill(fedId); break;
141  default : break;
142  }; // end switch
143  } // end for(di
144  } // end if( isearch
145  // slow down...
146  if(slowDown) usleep(100000);
147 
148 }
149 
150 //------------------------------------------------------------------
151 // Book MEs
152 //------------------------------------------------------------------
154 
155  iBooker.cd();
156  iBooker.setCurrentFolder(dirName_);
157 
158  std::string rawhid;
159  std::string errhid;
160  // Get collection name and instantiate Histo Id builder
161  edm::InputTag rawin = conf_.getParameter<edm::InputTag>( "RawInput" );
162  SiPixelHistogramId* RawHistogramId = new SiPixelHistogramId( rawin.label() );
163  edm::InputTag errin = conf_.getParameter<edm::InputTag>( "ErrorInput" );
164  SiPixelHistogramId* ErrorHistogramId = new SiPixelHistogramId( errin.label() );
165 
166  // Is a FED sending raw data
167  meRawWords_ = iBooker.book1D("FEDEntries","Number of raw words",40,-0.5,39.5);
168  meRawWords_->setAxisTitle("Number of raw words",1);
169 
170  // Number of CRC errors
171  meNCRCs_ = iBooker.book1D("FEDFatal","Number of fatal errors",40,-0.5,39.5);
172  meNCRCs_->setAxisTitle("Number of fatal errors",1);
173 
174  // Number of translation error words
175  meNErrors_ = iBooker.book1D("FEDNonFatal","Number of non-fatal errors",40,-0.5,39.5);
176  meNErrors_->setAxisTitle("Number of non-fatal errors",1);
177 
178  delete RawHistogramId;
179  delete ErrorHistogramId;
180 
181 }
182 
T getParameter(std::string const &) const
edm::ParameterSet conf_
SiPixelHLTSource(const edm::ParameterSet &conf)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void cd(void)
Definition: DQMStore.cc:268
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
MonitorElement * meNErrors_
edm::EDGetTokenT< edm::DetSetVector< SiPixelRawDataError > > errin_
MonitorElement * meNCRCs_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
virtual void bookMEs(DQMStore::IBooker &)
std::string dirName_
int iEvent
Definition: GenABIO.cc:230
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
bool isValid() const
Definition: HandleBase.h:75
edm::EDGetTokenT< FEDRawDataCollection > rawin_
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
MonitorElement * meRawWords_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
virtual void analyze(const edm::Event &, const edm::EventSetup &)
const T & get() const
Definition: EventSetup.h:56
bool isTrackerPixel(const GeomDetEnumerators::SubDetector m)
std::string const & label() const
Definition: InputTag.h:36
virtual void dqmBeginRun(const edm::Run &, edm::EventSetup const &)
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:346
volatile std::atomic< bool > shutdown_flag false
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104
edm::ESHandle< TrackerGeometry > pDD
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Pixel error – collection of errors and error information.
Definition: Run.h:43