Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <DQMOffline/Muon/src/MuonTrackResidualsTest.h>
00012
00013
00014 #include <FWCore/Framework/interface/Event.h>
00015 #include "DataFormats/Common/interface/Handle.h"
00016 #include <FWCore/Framework/interface/ESHandle.h>
00017 #include <FWCore/Framework/interface/MakerMacros.h>
00018 #include <FWCore/Framework/interface/EventSetup.h>
00019 #include <FWCore/ParameterSet/interface/ParameterSet.h>
00020
00021
00022 #include "DQMServices/Core/interface/DQMStore.h"
00023 #include "DQMServices/Core/interface/MonitorElement.h"
00024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00025 #include "FWCore/Framework/interface/Run.h"
00026
00027 #include <iostream>
00028 #include <stdio.h>
00029 #include <string>
00030 #include <math.h>
00031 #include "TF1.h"
00032
00033 using namespace edm;
00034 using namespace std;
00035
00036
00037 MuonTrackResidualsTest::MuonTrackResidualsTest(const edm::ParameterSet& ps){
00038 parameters = ps;
00039
00040 theDbe = edm::Service<DQMStore>().operator->();
00041
00042 prescaleFactor = parameters.getUntrackedParameter<int>("diagnosticPrescale", 1);
00043
00044 }
00045
00046
00047 MuonTrackResidualsTest::~MuonTrackResidualsTest(){
00048
00049 LogTrace(metname) << "DTResolutionTest: analyzed " << nevents << " events";
00050
00051 }
00052
00053
00054 void MuonTrackResidualsTest::beginJob(void){
00055
00056 metname = "trackResidualsTest";
00057 theDbe->setCurrentFolder("Muons/Tests/trackResidualsTest");
00058
00059 LogTrace(metname) << "[MuonTrackResidualsTest] beginJob: Parameters initialization"<<endl;
00060
00061
00062 string histName, MeanHistoName, SigmaHistoName, MeanHistoTitle, SigmaHistoTitle;
00063 vector<string> type;
00064 type.push_back("eta");
00065 type.push_back("theta");
00066 type.push_back("phi");
00067
00068
00069 for(unsigned int c=0; c<type.size(); c++){
00070
00071 MeanHistoName = "MeanTest_" + type[c];
00072 SigmaHistoName = "SigmaTest_" + type[c];
00073
00074 MeanHistoTitle = "Mean of the #" + type[c] + " residuals distribution";
00075 SigmaHistoTitle = "Sigma of the #" + type[c] + " residuals distribution";
00076
00077 histName = "Res_GlbSta_"+type[c];
00078 histoNames[type[c]].push_back(histName);
00079 histName = "Res_TkGlb_"+type[c];
00080 histoNames[type[c]].push_back(histName);
00081 histName = "Res_TkSta_"+type[c];
00082 histoNames[type[c]].push_back(histName);
00083
00084
00085 MeanHistos[type[c]] = theDbe->book1D(MeanHistoName.c_str(),MeanHistoTitle.c_str(),3,0.5,3.5);
00086 (MeanHistos[type[c]])->setBinLabel(1,"Res_StaGlb",1);
00087 (MeanHistos[type[c]])->setBinLabel(2,"Res_TkGlb",1);
00088 (MeanHistos[type[c]])->setBinLabel(3,"Res_TkSta",1);
00089
00090
00091 SigmaHistos[type[c]] = theDbe->book1D(SigmaHistoName.c_str(),SigmaHistoTitle.c_str(),3,0.5,3.5);
00092 (SigmaHistos[type[c]])->setBinLabel(1,"Res_StaGlb",1);
00093 (SigmaHistos[type[c]])->setBinLabel(2,"Res_TkGlb",1);
00094 (SigmaHistos[type[c]])->setBinLabel(3,"Res_TkSta",1);
00095
00096 }
00097
00098 nevents = 0;
00099
00100 }
00101
00102
00103 void MuonTrackResidualsTest::beginRun(Run const& run, EventSetup const& eSetup) {
00104
00105 LogTrace(metname)<<"[MuonTrackResidualsTest]: beginRun";
00106
00107 }
00108
00109 void MuonTrackResidualsTest::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00110
00111
00112
00113
00114
00115
00116 }
00117
00118
00119 void MuonTrackResidualsTest::analyze(const edm::Event& e, const edm::EventSetup& context){
00120
00121 nevents++;
00122 LogTrace(metname)<< "[MuonTrackResidualsTest]: "<<nevents<<" events";
00123
00124 }
00125
00126
00127
00128 void MuonTrackResidualsTest::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00129
00130
00131
00132
00133 nLumiSegs = lumiSeg.id().luminosityBlock();
00134
00135
00136 if ( nLumiSegs%prescaleFactor != 0 ) return;
00137
00138
00139 }
00140
00141
00142 void MuonTrackResidualsTest::endRun(Run const& run, EventSetup const& eSetup) {
00143
00144 LogTrace(metname)<<"[MuonTrackResidualsTest]: endRun, performing the DQM end of run client operation";
00145
00146 for(map<string, vector<string> > ::const_iterator histo = histoNames.begin();
00147 histo != histoNames.end();
00148 histo++) {
00149
00150 for (unsigned int type=0; type< (*histo).second.size(); type++){
00151
00152 string path = "Muons/MuonRecoAnalyzer/" + (*histo).second[type];
00153 MonitorElement * res_histo = theDbe->get(path);
00154 if (res_histo) {
00155
00156
00157 string GaussianCriterionName =
00158 parameters.getUntrackedParameter<string>("resDistributionTestName",
00159 "ResidualsDistributionGaussianTest");
00160 const QReport * GaussianReport = res_histo->getQReport(GaussianCriterionName);
00161 if(GaussianReport){
00162 LogTrace(metname) << "-------- histo : "<<(*histo).second[type]<<" "<<GaussianReport->getMessage()<<" ------- "<<GaussianReport->getStatus();
00163 }
00164 int BinNumber = type+1;
00165 float mean = (*res_histo).getMean(1);
00166 float sigma = (*res_histo).getRMS(1);
00167 MeanHistos.find((*histo).first)->second->setBinContent(BinNumber, mean);
00168 SigmaHistos.find((*histo).first)->second->setBinContent(BinNumber, sigma);
00169 }
00170 }
00171 }
00172
00173
00174
00175 string MeanCriterionName = parameters.getUntrackedParameter<string>("meanTestName","ResidualsMeanInRange");
00176 for(map<string, MonitorElement*>::const_iterator hMean = MeanHistos.begin();
00177 hMean != MeanHistos.end();
00178 hMean++) {
00179 const QReport * theMeanQReport = (*hMean).second->getQReport(MeanCriterionName);
00180 if(theMeanQReport) {
00181 vector<dqm::me_util::Channel> badChannels = theMeanQReport->getBadChannels();
00182 for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin();
00183 channel != badChannels.end(); channel++) {
00184 LogTrace(metname)<< "type:"<<(*hMean).first<<" Bad mean channels: "<<(*channel).getBin()<<" Contents : "<<(*channel).getContents()<<endl;
00185 }
00186 LogTrace(metname)<< "-------- type: "<<(*hMean).first<<" "<<theMeanQReport->getMessage()<<" ------- "<<theMeanQReport->getStatus()<<endl;
00187 }
00188 }
00189
00190
00191 string SigmaCriterionName = parameters.getUntrackedParameter<string>("sigmaTestName","ResidualsSigmaInRange");
00192 for(map<string, MonitorElement*>::const_iterator hSigma = SigmaHistos.begin();
00193 hSigma != SigmaHistos.end();
00194 hSigma++) {
00195 const QReport * theSigmaQReport = (*hSigma).second->getQReport(SigmaCriterionName);
00196 if(theSigmaQReport) {
00197 vector<dqm::me_util::Channel> badChannels = theSigmaQReport->getBadChannels();
00198 for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin();
00199 channel != badChannels.end(); channel++) {
00200 LogTrace(metname)<< "type:"<<(*hSigma).first<<" Bad sigma channels: "<<(*channel).getBin()<<" Contents : "<<(*channel).getContents()<<endl;
00201 }
00202 LogTrace(metname) << "-------- type: "<<(*hSigma).first<<" "<<theSigmaQReport->getMessage()<<" ------- "<<theSigmaQReport->getStatus()<<endl;
00203 }
00204 }
00205 }
00206
00207 void MuonTrackResidualsTest::endJob(){
00208
00209 LogTrace(metname)<< "[MuonTrackResidualsTest] endJob called!";
00210 theDbe->rmdir("Muons/Tests/trackResidualsTest");
00211
00212 }
00213
00214
00215