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  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
76  if(firstRun){
77  eventNo = 0;
78  // Build map
79  // Book Monitoring Elements
80  bookMEs();
81  firstRun = false;
82  }
83 }
84 
85 
87 
88  if(saveFile) {
89  LogInfo ("PixelDQM") << " SiPixelHLTSource::endJob - Saving Root File " << std::endl;
91  theDMBE->save( outputFile.c_str() );
92  }
93 
94 }
95 
96 //------------------------------------------------------------------
97 // Method called for every event
98 //------------------------------------------------------------------
100 {
101  eventNo++;
102  // get raw input data
104  iEvent.getByLabel( rawin_, rawinput );
105  // get error input data
107  iEvent.getByLabel( errin_, errorinput );
108  if (!errorinput.isValid()) return;
109 
110  int fedId;
111 
112  for(fedId = 0; fedId <= 39; fedId++) {
113  //get event data for this fed
114  const FEDRawData& fedRawData = rawinput->FEDData( fedId );
115  if (fedRawData.size() != 0) (meRawWords_)->Fill(fedId);
116  } // end for
117 
119 
120  for(TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++){
121  if( ((*it)->subDetector()==GeomDetEnumerators::PixelBarrel) || ((*it)->subDetector()==GeomDetEnumerators::PixelEndcap) ){
122  uint32_t detId = (*it)->geographicalId();
123  edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = errorinput->find(detId);
124  if( isearch != errorinput->end() ) {
125  for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
126  fedId = di->getFedId(); // FED the error came from
127  int errorType = di->getType(); // type of error
128  switch(errorType) {
129  case(35) : (meNErrors_)->Fill(fedId); break;
130  case(36) : (meNErrors_)->Fill(fedId); break;
131  case(37) : (meNErrors_)->Fill(fedId); break;
132  case(38) : (meNErrors_)->Fill(fedId); break;
133  default : break;
134  }; // end switch
135  } // end for(di
136  } // end if( isearch
137  } // end if( ((*it)->subDetector()
138  } // for(TrackerGeometry
139 
140  edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = errorinput->find(0xffffffff);
141 
142  if( isearch != errorinput->end() ) { // Not at empty iterator
143  for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
144  fedId = di->getFedId(); // FED the error came from
145  int errorType = di->getType(); // type of error
146  switch(errorType) {
147  case(35) : (meNErrors_)->Fill(fedId); break;
148  case(36) : (meNErrors_)->Fill(fedId); break;
149  case(37) : (meNErrors_)->Fill(fedId); break;
150  case(38) : (meNErrors_)->Fill(fedId); break;
151  case(39) : (meNCRCs_)->Fill(fedId); break;
152  default : break;
153  }; // end switch
154  } // end for(di
155  } // end if( isearch
156  // slow down...
157  if(slowDown) usleep(100000);
158 
159 }
160 
161 //------------------------------------------------------------------
162 // Book MEs
163 //------------------------------------------------------------------
165 
166  theDMBE->cd();
168 
169  std::string rawhid;
170  std::string errhid;
171  // Get collection name and instantiate Histo Id builder
172  edm::InputTag rawin = conf_.getParameter<edm::InputTag>( "RawInput" );
173  SiPixelHistogramId* RawHistogramId = new SiPixelHistogramId( rawin.label() );
174  edm::InputTag errin = conf_.getParameter<edm::InputTag>( "ErrorInput" );
175  SiPixelHistogramId* ErrorHistogramId = new SiPixelHistogramId( errin.label() );
176  // Get DQM interface
178 
179  // Is a FED sending raw data
180  meRawWords_ = theDMBE->book1D("FEDEntries","Number of raw words",40,-0.5,39.5);
181  meRawWords_->setAxisTitle("Number of raw words",1);
182 
183  // Number of CRC errors
184  meNCRCs_ = theDMBE->book1D("FEDFatal","Number of fatal errors",40,-0.5,39.5);
185  meNCRCs_->setAxisTitle("Number of fatal errors",1);
186 
187  // Number of translation error words
188  meNErrors_ = theDMBE->book1D("FEDNonFatal","Number of non-fatal errors",40,-0.5,39.5);
189  meNErrors_->setAxisTitle("Number of non-fatal errors",1);
190 
191  delete RawHistogramId;
192  delete ErrorHistogramId;
193 
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:411
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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:2118
MonitorElement * meNErrors_
MonitorElement * meNCRCs_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
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:361
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:42
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:34
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:434
Definition: Run.h:36