00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "DQM/DTMonitorClient/src/DTLocalTriggerTest.h"
00012
00013
00014 #include "FWCore/Framework/interface/EventSetup.h"
00015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00016 #include "DQMServices/Core/interface/MonitorElement.h"
00017 #include "DQMServices/Core/interface/DQMStore.h"
00018
00019
00020 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00021 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00022
00023
00024 #include "TF1.h"
00025 #include "TProfile.h"
00026
00027
00028
00029 #include <iostream>
00030 #include <sstream>
00031
00032 using namespace edm;
00033 using namespace std;
00034
00035
00036 DTLocalTriggerTest::DTLocalTriggerTest(const edm::ParameterSet& ps){
00037
00038 setConfig(ps,"DTLocalTrigger");
00039 baseFolder = "DT/03-LocalTrigger/";
00040
00041 }
00042
00043
00044 DTLocalTriggerTest::~DTLocalTriggerTest(){
00045
00046 }
00047
00048 void DTLocalTriggerTest::beginJob(const edm::EventSetup& c){
00049
00050 DTLocalTriggerBaseTest::beginJob(c);
00051
00052
00053 vector<string>::const_iterator iTr = trigSources.begin();
00054 vector<string>::const_iterator trEnd = trigSources.end();
00055 vector<string>::const_iterator iHw = hwSources.begin();
00056 vector<string>::const_iterator hwEnd = hwSources.end();
00057
00058
00059
00060 if(parameters.getUntrackedParameter<bool>("staticBooking", true)){
00061 for (; iTr != trEnd; ++iTr){
00062 trigSource = (*iTr);
00063 for (; iHw != hwEnd; ++iHw){
00064 hwSource = (*iHw);
00065
00066 for (int wh=-2; wh<=2; ++wh){
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 bookWheelHistos(wh,"","CorrectBXPhi");
00077 bookWheelHistos(wh,"","ResidualBXPhi");
00078 bookWheelHistos(wh,"","CorrFractionPhi");
00079 bookWheelHistos(wh,"","2ndFractionPhi");
00080 bookWheelHistos(wh,"","TriggerInclusivePhi");
00081 if (hwSource!="DCC") {
00082 bookWheelHistos(wh,"","CorrectBXTheta");
00083 bookWheelHistos(wh,"","HFractionTheta");
00084 }
00085 }
00086 }
00087 }
00088 }
00089
00090 for (iTr = trigSources.begin(); iTr != trEnd; ++iTr){
00091 trigSource = (*iTr);
00092 for (iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
00093 hwSource = (*iHw);
00094
00095 for (int wh=-2; wh<=2; ++wh){
00096 bookWheelHistos(wh,"","CorrFractionSummary");
00097 bookWheelHistos(wh,"","2ndFractionSummary");
00098 }
00099 bookCmsHistos("CorrFractionSummary");
00100 bookCmsHistos("2ndFractionSummary");
00101 }
00102 }
00103
00104 }
00105
00106 void DTLocalTriggerTest::runClientDiagnostic() {
00107
00108
00109 for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr){
00110 trigSource = (*iTr);
00111 for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
00112 hwSource = (*iHw);
00113
00114 for (int stat=1; stat<=4; ++stat){
00115 for (int wh=-2; wh<=2; ++wh){
00116 for (int sect=1; sect<=12; ++sect){
00117 DTChamberId chId(wh,stat,sect);
00118
00119
00120
00121
00122
00123 TH2F * BXvsQual = getHisto<TH2F>(dbe->get(getMEName("BXvsQual","LocalTriggerPhi", chId)));
00124 TH1F * BestQual = getHisto<TH1F>(dbe->get(getMEName("BestQual","LocalTriggerPhi", chId)));
00125 TH2F * Flag1stvsQual = getHisto<TH2F>(dbe->get(getMEName("Flag1stvsQual","LocalTriggerPhi", chId)));
00126 if (BXvsQual && Flag1stvsQual && BestQual) {
00127
00128 int corrSummary = 1;
00129 int secondSummary = 1;
00130
00131 if (BestQual->GetEntries()>1) {
00132
00133 TH1D* BXHH = BXvsQual->ProjectionY("",6,7,"");
00134 TH1D* Flag1st = Flag1stvsQual->ProjectionY();
00135 int BXOK_bin = BXHH->GetEntries()>=1 ? BXHH->GetMaximumBin() : 51;
00136 double BXMean = BXHH->GetEntries()>=1 ? BXHH->GetMean() : 51;
00137 double BX_OK = BXvsQual->GetYaxis()->GetBinCenter(BXOK_bin);
00138 double trigsFlag2nd = Flag1st->GetBinContent(2);
00139 double trigs = Flag1st->GetEntries();
00140 double besttrigs = BestQual->GetEntries();
00141 double besttrigsCorr = BestQual->Integral(5,7,"");
00142 delete BXHH;
00143 delete Flag1st;
00144
00145 double corrFrac = besttrigsCorr/besttrigs;
00146 double secondFrac = trigsFlag2nd/trigs;
00147 if (corrFrac < parameters.getUntrackedParameter<double>("corrFracError",.5)){
00148 corrSummary = 2;
00149 }
00150 else if (corrFrac < parameters.getUntrackedParameter<double>("corrFracWarning",.6)){
00151 corrSummary = 3;
00152 }
00153 else {
00154 corrSummary = 0;
00155 }
00156 if (secondFrac > parameters.getUntrackedParameter<double>("secondFracError",.2)){
00157 secondSummary = 2;
00158 }
00159 else if (secondFrac > parameters.getUntrackedParameter<double>("secondFracWarning",.1)){
00160 secondSummary = 3;
00161 }
00162 else {
00163 secondSummary = 0;
00164 }
00165
00166
00167
00168
00169
00170
00171 if( whME[wh].find(fullName("CorrectBXPhi")) == whME[wh].end() ){
00172 bookWheelHistos(wh,"","ResidualBXPhi");
00173 bookWheelHistos(wh,"","CorrectBXPhi");
00174 bookWheelHistos(wh,"","CorrFractionPhi");
00175 bookWheelHistos(wh,"","2ndFractionPhi");
00176 bookWheelHistos(wh,"","TriggerInclusivePhi");
00177 }
00178
00179
00180
00181
00182
00183 std::map<std::string,MonitorElement*> *innerME = &(whME[wh]);
00184 innerME->find(fullName("CorrectBXPhi"))->second->setBinContent(sect,stat,BX_OK+0.00001);
00185 innerME->find(fullName("ResidualBXPhi"))->second->setBinContent(sect,stat,round(25.*(BXMean-BX_OK))+0.00001);
00186 innerME->find(fullName("CorrFractionPhi"))->second->setBinContent(sect,stat,corrFrac);
00187 innerME->find(fullName("TriggerInclusivePhi"))->second->setBinContent(sect,stat,besttrigs);
00188 innerME->find(fullName("2ndFractionPhi"))->second->setBinContent(sect,stat,secondFrac);
00189
00190 }
00191
00192 whME[wh].find(fullName("CorrFractionSummary"))->second->setBinContent(sect,stat,corrSummary);
00193 whME[wh].find(fullName("2ndFractionSummary"))->second->setBinContent(sect,stat,secondSummary);
00194
00195 }
00196
00197
00198 TH2F * ThetaBXvsQual = getHisto<TH2F>(dbe->get(getMEName("ThetaBXvsQual","LocalTriggerTheta", chId)));
00199 TH1F * ThetaBestQual = getHisto<TH1F>(dbe->get(getMEName("ThetaBestQual","LocalTriggerTheta", chId)));
00200
00201
00202 if (ThetaBXvsQual && ThetaBestQual && stat<4 && ThetaBestQual->GetEntries()>1) {
00203 TH1D* BXH = ThetaBXvsQual->ProjectionY("",4,4,"");
00204 int BXOK_bin = BXH->GetEffectiveEntries()>=1 ? BXH->GetMaximumBin(): 10;
00205 double BX_OK = ThetaBXvsQual->GetYaxis()->GetBinCenter(BXOK_bin);
00206 double trigs = ThetaBestQual->GetEntries();
00207 double trigsH = ThetaBestQual->GetBinContent(4);
00208 delete BXH;
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218 if( whME[wh].find(fullName("HFractionTheta")) == whME[wh].end() ){
00219 bookWheelHistos(wh,"","CorrectBXTheta");
00220 bookWheelHistos(wh,"","HFractionTheta");
00221 }
00222 std::map<std::string,MonitorElement*> *innerME = &(whME.find(wh)->second);
00223 innerME->find(fullName("CorrectBXTheta"))->second->setBinContent(sect,stat,BX_OK);
00224 innerME->find(fullName("HFractionTheta"))->second->setBinContent(sect,stat,trigsH/trigs);
00225
00226 }
00227
00228 }
00229 }
00230 }
00231 }
00232 }
00233
00234 for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr){
00235 trigSource = (*iTr);
00236 for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
00237 hwSource = (*iHw);
00238 for (int wh=-2; wh<=2; ++wh){
00239 std::map<std::string,MonitorElement*> *innerME = &(whME[wh]);
00240 TH2F* corrWhSummary = getHisto<TH2F>(innerME->find(fullName("CorrFractionSummary"))->second);
00241 TH2F* secondWhSummary = getHisto<TH2F>(innerME->find(fullName("2ndFractionSummary"))->second);
00242 for (int sect=1; sect<=12; ++sect){
00243 int corrErr = 0;
00244 int secondErr = 0;
00245 int corrNoData = 0;
00246 int secondNoData = 0;
00247 for (int stat=1; stat<=4; ++stat){
00248 switch (static_cast<int>(corrWhSummary->GetBinContent(sect,stat))) {
00249 case 1:
00250 corrNoData++;
00251 case 2:
00252 corrErr++;
00253 }
00254 switch (static_cast<int>(secondWhSummary->GetBinContent(sect,stat))) {
00255 case 1:
00256 secondNoData++;
00257 case 2:
00258 secondErr++;
00259 }
00260 }
00261 if (corrNoData == 4) corrErr = 5;
00262 if (secondNoData == 4) secondErr = 5;
00263 cmsME.find(fullName("CorrFractionSummary"))->second->setBinContent(sect,wh+3,corrErr);
00264 cmsME.find(fullName("2ndFractionSummary"))->second->setBinContent(sect,wh+3,secondErr);
00265 }
00266 }
00267 }
00268 }
00269
00270 }
00271