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
41 //
42 #include <string>
43 #include <stdlib.h>
44 
45 using namespace std;
46 using namespace edm;
47 
49  conf_(iConfig),
50  rawin_( conf_.getParameter<edm::InputTag>( "RawInput" ) ),
51  errin_( conf_.getParameter<edm::InputTag>( "ErrorInput" ) ),
52  saveFile( conf_.getUntrackedParameter<bool>("saveFile",false) ),
53  slowDown( conf_.getUntrackedParameter<bool>("slowDown",false) ),
54  dirName_( conf_.getUntrackedParameter<std::string>("DirName","Pixel/FEDIntegrity/") )
55 {
57  LogInfo ("PixelDQM") << "SiPixelHLTSource::SiPixelHLTSource: Got DQM BackEnd interface"<<endl;
58 }
59 
60 
62 {
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 
68 
70  firstRun = true;
71 }
72 
74  LogInfo ("PixelDQM") << " SiPixelHLTSource::beginJob - Initialisation ... " << std::endl;
75 
76  if(firstRun){
77  eventNo = 0;
78  // Build map
79  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
80  // Book Monitoring Elements
81  bookMEs();
82  firstRun = false;
83  }
84 }
85 
86 
88 
89  if(saveFile) {
90  LogInfo ("PixelDQM") << " SiPixelHLTSource::endJob - Saving Root File " << std::endl;
91  std::string outputFile = conf_.getParameter<std::string>("outputFile");
92  theDMBE->save( outputFile.c_str() );
93  }
94 
95 }
96 
97 //------------------------------------------------------------------
98 // Method called for every event
99 //------------------------------------------------------------------
101 {
102  eventNo++;
103  // get raw input data
105  iEvent.getByLabel( rawin_, rawinput );
106  // get error input data
108  iEvent.getByLabel( errin_, errorinput );
109  if (!errorinput.isValid()) return;
110 
111  int fedId;
112 
113  for(fedId = 0; fedId <= 39; fedId++) {
114  //get event data for this fed
115  const FEDRawData& fedRawData = rawinput->FEDData( fedId );
116  if (fedRawData.size() != 0) (meRawWords_)->Fill(fedId);
117  } // end for
118 
120 
121  for(TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++){
122  if( ((*it)->subDetector()==GeomDetEnumerators::PixelBarrel) || ((*it)->subDetector()==GeomDetEnumerators::PixelEndcap) ){
123  uint32_t detId = (*it)->geographicalId();
124  edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = errorinput->find(detId);
125  if( isearch != errorinput->end() ) {
126  for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
127  fedId = di->getFedId(); // FED the error came from
128  int errorType = di->getType(); // type of error
129  switch(errorType) {
130  case(35) : (meNErrors_)->Fill(fedId); break;
131  case(36) : (meNErrors_)->Fill(fedId); break;
132  case(37) : (meNErrors_)->Fill(fedId); break;
133  case(38) : (meNErrors_)->Fill(fedId); break;
134  default : break;
135  }; // end switch
136  } // end for(di
137  } // end if( isearch
138  } // end if( ((*it)->subDetector()
139  } // for(TrackerGeometry
140 
141  edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = errorinput->find(0xffffffff);
142 
143  if( isearch != errorinput->end() ) { // Not at empty iterator
144  for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
145  fedId = di->getFedId(); // FED the error came from
146  int errorType = di->getType(); // type of error
147  switch(errorType) {
148  case(35) : (meNErrors_)->Fill(fedId); break;
149  case(36) : (meNErrors_)->Fill(fedId); break;
150  case(37) : (meNErrors_)->Fill(fedId); break;
151  case(38) : (meNErrors_)->Fill(fedId); break;
152  case(39) : (meNCRCs_)->Fill(fedId); break;
153  default : break;
154  }; // end switch
155  } // end for(di
156  } // end if( isearch
157  // slow down...
158  if(slowDown) usleep(100000);
159 
160 }
161 
162 //------------------------------------------------------------------
163 // Book MEs
164 //------------------------------------------------------------------
166 
167  theDMBE->cd();
169 
170  std::string rawhid;
171  std::string errhid;
172  // Get collection name and instantiate Histo Id builder
173  edm::InputTag rawin = conf_.getParameter<edm::InputTag>( "RawInput" );
174  SiPixelHistogramId* RawHistogramId = new SiPixelHistogramId( rawin.label() );
175  edm::InputTag errin = conf_.getParameter<edm::InputTag>( "ErrorInput" );
176  SiPixelHistogramId* ErrorHistogramId = new SiPixelHistogramId( errin.label() );
177  // Get DQM interface
179 
180  // Is a FED sending raw data
181  meRawWords_ = theDMBE->book1D("FEDEntries","Number of raw words",40,-0.5,39.5);
182  meRawWords_->setAxisTitle("Number of raw words",1);
183 
184  // Number of CRC errors
185  meNCRCs_ = theDMBE->book1D("FEDFatal","Number of fatal errors",40,-0.5,39.5);
186  meNCRCs_->setAxisTitle("Number of fatal errors",1);
187 
188  // Number of translation error words
189  meNErrors_ = theDMBE->book1D("FEDNonFatal","Number of non-fatal errors",40,-0.5,39.5);
190  meNErrors_->setAxisTitle("Number of non-fatal errors",1);
191 
192  delete RawHistogramId;
193  delete ErrorHistogramId;
194 
195 }
T getParameter(std::string const &) const
edm::ParameterSet conf_
virtual void endJob()
SiPixelHLTSource(const edm::ParameterSet &conf)
virtual void beginJob()
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:209
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:1898
MonitorElement * meNErrors_
MonitorElement * meNCRCs_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
std::string dirName_
int iEvent
Definition: GenABIO.cc:243
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
virtual void beginRun(const edm::Run &, edm::EventSetup const &)
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:356
MonitorElement * meRawWords_
virtual void analyze(const edm::Event &, const edm::EventSetup &)
const T & get() const
Definition: EventSetup.h:55
std::string const & label() const
Definition: InputTag.h:25
edm::InputTag rawin_
edm::InputTag errin_
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:341
collection_type::const_iterator const_iterator
Definition: DetSet.h:32
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
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)
virtual void bookMEs()
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
Definition: Run.h:32