Go to the documentation of this file.00001
00002
00003
00004
00005
00017
00018
00019
00020
00021 #include "FWCore/ServiceRegistry/interface/Service.h"
00022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00023
00024 #include "DQM/SiPixelMonitorRawData/interface/SiPixelHLTSource.h"
00025 #include "DQM/SiPixelCommon/interface/SiPixelFolderOrganizer.h"
00026 #include "DQM/SiPixelCommon/interface/SiPixelHistogramId.h"
00027 #include "DQMServices/Core/interface/DQMStore.h"
00028
00029 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00030 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00031 #include "Geometry/CommonDetUnit/interface/GeomDetEnumerators.h"
00032 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00033 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
00034
00035 #include "DataFormats/DetId/interface/DetId.h"
00036 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00037 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00038 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00039 #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h"
00040 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"
00041
00042 #include <string>
00043 #include <stdlib.h>
00044
00045 using namespace std;
00046 using namespace edm;
00047
00048 SiPixelHLTSource::SiPixelHLTSource(const edm::ParameterSet& iConfig) :
00049 conf_(iConfig),
00050 rawin_( conf_.getParameter<edm::InputTag>( "RawInput" ) ),
00051 errin_( conf_.getParameter<edm::InputTag>( "ErrorInput" ) ),
00052 saveFile( conf_.getUntrackedParameter<bool>("saveFile",false) ),
00053 slowDown( conf_.getUntrackedParameter<bool>("slowDown",false) ),
00054 dirName_( conf_.getUntrackedParameter<std::string>("DirName","Pixel/FEDIntegrity/") )
00055 {
00056 theDMBE = edm::Service<DQMStore>().operator->();
00057 LogInfo ("PixelDQM") << "SiPixelHLTSource::SiPixelHLTSource: Got DQM BackEnd interface"<<endl;
00058 }
00059
00060
00061 SiPixelHLTSource::~SiPixelHLTSource()
00062 {
00063
00064
00065 LogInfo ("PixelDQM") << "SiPixelHLTSource::~SiPixelHLTSource: Destructor"<<endl;
00066 }
00067
00068
00069 void SiPixelHLTSource::beginJob(){
00070 firstRun = true;
00071 }
00072
00073 void SiPixelHLTSource::beginRun(const edm::Run& r, const edm::EventSetup& iSetup){
00074 LogInfo ("PixelDQM") << " SiPixelHLTSource::beginJob - Initialisation ... " << std::endl;
00075
00076 if(firstRun){
00077 eventNo = 0;
00078
00079 iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
00080
00081 bookMEs();
00082 firstRun = false;
00083 }
00084 }
00085
00086
00087 void SiPixelHLTSource::endJob(void){
00088
00089 if(saveFile) {
00090 LogInfo ("PixelDQM") << " SiPixelHLTSource::endJob - Saving Root File " << std::endl;
00091 std::string outputFile = conf_.getParameter<std::string>("outputFile");
00092 theDMBE->save( outputFile.c_str() );
00093 }
00094
00095 }
00096
00097
00098
00099
00100 void SiPixelHLTSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00101 {
00102 eventNo++;
00103
00104 edm::Handle< FEDRawDataCollection > rawinput;
00105 iEvent.getByLabel( rawin_, rawinput );
00106
00107 edm::Handle< edm::DetSetVector<SiPixelRawDataError> > errorinput;
00108 iEvent.getByLabel( errin_, errorinput );
00109 if (!errorinput.isValid()) return;
00110
00111 int fedId;
00112
00113 for(fedId = 0; fedId <= 39; fedId++) {
00114
00115 const FEDRawData& fedRawData = rawinput->FEDData( fedId );
00116 if (fedRawData.size() != 0) (meRawWords_)->Fill(fedId);
00117 }
00118
00119 edm::DetSet<SiPixelRawDataError>::const_iterator di;
00120
00121 for(TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++){
00122 if( ((*it)->subDetector()==GeomDetEnumerators::PixelBarrel) || ((*it)->subDetector()==GeomDetEnumerators::PixelEndcap) ){
00123 uint32_t detId = (*it)->geographicalId();
00124 edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = errorinput->find(detId);
00125 if( isearch != errorinput->end() ) {
00126 for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
00127 fedId = di->getFedId();
00128 int errorType = di->getType();
00129 switch(errorType) {
00130 case(35) : (meNErrors_)->Fill(fedId); break;
00131 case(36) : (meNErrors_)->Fill(fedId); break;
00132 case(37) : (meNErrors_)->Fill(fedId); break;
00133 case(38) : (meNErrors_)->Fill(fedId); break;
00134 default : break;
00135 };
00136 }
00137 }
00138 }
00139 }
00140
00141 edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = errorinput->find(0xffffffff);
00142
00143 if( isearch != errorinput->end() ) {
00144 for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
00145 fedId = di->getFedId();
00146 int errorType = di->getType();
00147 switch(errorType) {
00148 case(35) : (meNErrors_)->Fill(fedId); break;
00149 case(36) : (meNErrors_)->Fill(fedId); break;
00150 case(37) : (meNErrors_)->Fill(fedId); break;
00151 case(38) : (meNErrors_)->Fill(fedId); break;
00152 case(39) : (meNCRCs_)->Fill(fedId); break;
00153 default : break;
00154 };
00155 }
00156 }
00157
00158 if(slowDown) usleep(100000);
00159
00160 }
00161
00162
00163
00164
00165 void SiPixelHLTSource::bookMEs(){
00166
00167 theDMBE->cd();
00168 theDMBE->setCurrentFolder(dirName_);
00169
00170 std::string rawhid;
00171 std::string errhid;
00172
00173 edm::InputTag rawin = conf_.getParameter<edm::InputTag>( "RawInput" );
00174 SiPixelHistogramId* RawHistogramId = new SiPixelHistogramId( rawin.label() );
00175 edm::InputTag errin = conf_.getParameter<edm::InputTag>( "ErrorInput" );
00176 SiPixelHistogramId* ErrorHistogramId = new SiPixelHistogramId( errin.label() );
00177
00178 DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00179
00180
00181 meRawWords_ = theDMBE->book1D("FEDEntries","Number of raw words",40,-0.5,39.5);
00182 meRawWords_->setAxisTitle("Number of raw words",1);
00183
00184
00185 meNCRCs_ = theDMBE->book1D("FEDFatal","Number of fatal errors",40,-0.5,39.5);
00186 meNCRCs_->setAxisTitle("Number of fatal errors",1);
00187
00188
00189 meNErrors_ = theDMBE->book1D("FEDNonFatal","Number of non-fatal errors",40,-0.5,39.5);
00190 meNErrors_->setAxisTitle("Number of non-fatal errors",1);
00191
00192 delete RawHistogramId;
00193 delete ErrorHistogramId;
00194
00195 }