00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "DQM/L1TMonitor/interface/L1TFED.h"
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 #include "DQMServices/Core/interface/MonitorElement.h"
00013 #include "DataFormats/FEDRawData/interface/FEDHeader.h"
00014 #include "DataFormats/FEDRawData/interface/FEDTrailer.h"
00015
00016 using namespace std;
00017 using namespace edm;
00018
00019 L1TFED::L1TFED(const ParameterSet& ps)
00020 {
00021
00022
00023 verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
00024
00025 if(verbose_) cout << "L1TFED: constructor...." << endl;
00026
00027
00028 dbe = NULL;
00029 if ( ps.getUntrackedParameter<bool>("DQMStore", false) )
00030 {
00031 dbe = Service<DQMStore>().operator->();
00032 dbe->setVerbose(0);
00033 }
00034
00035 outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
00036 if ( outputFile_.size() != 0 ) {
00037 cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
00038 }
00039
00040 bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
00041 if(disable){
00042 outputFile_="";
00043 }
00044
00045 l1feds_ = ps.getParameter<std::vector<int> >("L1FEDS");
00046
00047
00048 if ( dbe !=NULL ) {
00049 dbe->setCurrentFolder("L1T/FEDIntegrity");
00050 }
00051
00052
00053 }
00054
00055 L1TFED::~L1TFED()
00056 {
00057 }
00058
00059 void L1TFED::beginJob(const EventSetup& c)
00060 {
00061
00062 nev_ = 0;
00063
00064
00065 DQMStore* dbe = 0;
00066 dbe = Service<DQMStore>().operator->();
00067
00068 if ( dbe ) {
00069 dbe->setCurrentFolder("L1T/FEDIntegrity");
00070 dbe->rmdir("L1T/FEDIntegrity");
00071 }
00072
00073
00074 if ( dbe )
00075 {
00076 dbe->setCurrentFolder("L1T/FEDIntegrity");
00077
00078 fedentries = dbe->book1D("FEDEntries", "Fed ID occupancy", l1feds_.size(), 0.,l1feds_.size() );
00079 fedfatal = dbe->book1D("FEDFatal", "Fed ID non present ", l1feds_.size(), 0., l1feds_.size());
00080 fednonfatal = dbe->book1D("FEDNonFatal", "Fed corrupted data ", l1feds_.size(), 0.,l1feds_.size() );
00081 hfedprof = dbe->bookProfile("fedprofile","FED Size by ID", l1feds_.size(), 0., l1feds_.size(),0,0.,5000.);
00082 for(int i=0;i<l1feds_.size();i++){
00083 ostringstream sfed;
00084 sfed << l1feds_[i];
00085 fedentries->setBinLabel(i+1,"FED "+ sfed.str());
00086 fedfatal->setBinLabel(i+1,"FED "+ sfed.str());
00087 fednonfatal->setBinLabel(i+1,"FED "+ sfed.str());
00088
00089
00090 }
00091
00092 hfedsize = dbe->book1D("fedsize","FED Size Distribution",100,0.,10000.);
00093
00094 }
00095 }
00096
00097
00098 void L1TFED::endJob(void)
00099 {
00100
00101 if(verbose_) std::cout << "L1T FED Integrity: end job...." << std::endl;
00102 LogInfo("EndJob") << "analyzed " << nev_ << " events";
00103
00104 if ( outputFile_.size() != 0 && dbe ) dbe->save(outputFile_);
00105
00106 return;
00107 }
00108
00109 void L1TFED::analyze(const Event& e, const EventSetup& c)
00110 {
00111 nev_++;
00112 if(verbose_) cout << "L1T FED Integrity: analyze...." << endl;
00113
00114 edm::Handle<FEDRawDataCollection> rawdata;
00115 bool t = e.getByType(rawdata);
00116
00117 if ( ! t ) {
00118 LogDebug("Product") << "can't find FEDRawDataCollection ";
00119 }
00120
00121 else {
00122
00123 if(verbose_) cout << "fedlist size = " << l1feds_.size() << endl;
00124
00125 for (int i = 0; i<l1feds_.size(); i++){
00126 int fedId = l1feds_[i];
00127 if(verbose_) cout << "fedId = " << fedId << endl;
00128
00129 const FEDRawData & data = rawdata->FEDData(fedId);
00130
00131 if(size_t size=data.size()){
00132
00133 fedentries->Fill(i);
00134 hfedsize->Fill(float(size));
00135 hfedprof->Fill(float(i),float(size));
00136 if(verbose_) cout << "header check = " << FEDHeader(data.data()).check() << endl;
00137 if(verbose_) cout << "trailer check = " << FEDTrailer(data.data()).check() << endl;
00138
00139 if(!FEDHeader(data.data()).check()) fedfatal->Fill(i);
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 } else {
00157
00158 if(verbose_) cout << "empty fed " << i << endl;
00159 fedfatal->Fill(i);
00160
00161 }
00162 }
00163
00164 }
00165
00166 }
00167
00168