00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "DQM/DTMonitorClient/src/DTLocalTriggerBaseTest.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 DTLocalTriggerBaseTest::~DTLocalTriggerBaseTest(){
00037
00038 LogVerbatim(category()) << "[" << testName << "Test]: analyzed " << nevents << " events";
00039
00040 }
00041
00042 void DTLocalTriggerBaseTest::beginJob(){
00043
00044 LogVerbatim(category()) << "[" << testName << "Test]: BeginJob";
00045 nevents = 0;
00046 nLumiSegs = 0;
00047
00048 }
00049
00050 void DTLocalTriggerBaseTest::beginRun(Run const& run, EventSetup const& context) {
00051
00052 LogVerbatim(category()) << "[" << testName << "Test]: BeginRun";
00053 context.get<MuonGeometryRecord>().get(muonGeom);
00054
00055 }
00056
00057 void DTLocalTriggerBaseTest::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00058
00059 LogTrace(category()) <<"[" << testName << "Test]: Begin of LS transition";
00060
00061
00062 run = lumiSeg.run();
00063
00064 }
00065
00066
00067 void DTLocalTriggerBaseTest::analyze(const edm::Event& e, const edm::EventSetup& context){
00068
00069 nevents++;
00070 LogTrace(category()) << "[" << testName << "Test]: "<<nevents<<" events";
00071
00072 }
00073
00074
00075 void DTLocalTriggerBaseTest::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& context) {
00076
00077 if (!runOnline) return;
00078
00079 LogVerbatim("DTDQM|DTMonitorClient|DTLocalTriggerTest") <<"[" << testName << "Test]: End of LS transition, performing the DQM client operation";
00080
00081
00082 nLumiSegs++;
00083 if ( nLumiSegs%prescaleFactor != 0 ) return;
00084
00085 LogVerbatim("DTDQM|DTMonitorClient|DTLocalTriggerTest") <<"[" << testName << "Test]: "<<nLumiSegs<<" updates";
00086 runClientDiagnostic();
00087
00088 }
00089
00090
00091 void DTLocalTriggerBaseTest::endJob(){
00092
00093 LogTrace(category()) << "[" << testName << "Test] endJob called!";
00094
00095 }
00096
00097
00098 void DTLocalTriggerBaseTest::endRun(Run const& run, EventSetup const& context) {
00099
00100 LogTrace(category()) << "[" << testName << "Test] endRun called!";
00101
00102 if (!runOnline) {
00103 LogVerbatim(category()) << "[" << testName << "Test] Client called in offline mode, performing client operations";
00104 runClientDiagnostic();
00105 }
00106
00107 }
00108
00109
00110 void DTLocalTriggerBaseTest::setConfig(const edm::ParameterSet& ps, string name){
00111
00112 testName=name;
00113
00114 LogTrace(category()) << "[" << testName << "Test]: Constructor";
00115
00116 sourceFolder = ps.getUntrackedParameter<string>("folderRoot", "");
00117 runOnline = ps.getUntrackedParameter<bool>("runOnline",true);
00118 hwSources = ps.getUntrackedParameter<vector<string> >("hwSources");
00119
00120 if (ps.getUntrackedParameter<bool>("localrun",true)) {
00121 trigSources.push_back("");
00122 }
00123 else {
00124 trigSources = ps.getUntrackedParameter<vector<string> >("trigSources");
00125 }
00126
00127 parameters = ps;
00128 nevents = 0;
00129 dbe = edm::Service<DQMStore>().operator->();
00130
00131 prescaleFactor = parameters.getUntrackedParameter<int>("diagnosticPrescale", 1);
00132
00133 }
00134
00135
00136 string DTLocalTriggerBaseTest::fullName (string htype) {
00137
00138 return hwSource + "_" + htype + trigSource;
00139
00140 }
00141
00142 string DTLocalTriggerBaseTest::getMEName(string histoTag, string subfolder, const DTChamberId & chambid) {
00143
00144 stringstream wheel; wheel << chambid.wheel();
00145 stringstream station; station << chambid.station();
00146 stringstream sector; sector << chambid.sector();
00147
00148 string folderName = topFolder(hwSource=="DCC") + "Wheel" + wheel.str() +
00149 "/Sector" + sector.str() + "/Station" + station.str() + "/" ;
00150 if (subfolder!="") { folderName += subfolder + "/"; }
00151
00152 string histoname = sourceFolder + folderName
00153 + fullName(histoTag)
00154 + "_W" + wheel.str()
00155 + "_Sec" + sector.str()
00156 + "_St" + station.str();
00157
00158 return histoname;
00159
00160 }
00161
00162 string DTLocalTriggerBaseTest::getMEName(string histoTag, string subfolder, int wh) {
00163
00164 stringstream wheel; wheel << wh;
00165
00166 string folderName = topFolder(hwSource=="DCC") + "Wheel" + wheel.str() + "/";
00167 if (subfolder!="") { folderName += subfolder + "/"; }
00168
00169 string histoname = sourceFolder + folderName
00170 + fullName(histoTag) + "_W" + wheel.str();
00171
00172 return histoname;
00173
00174 }
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200 void DTLocalTriggerBaseTest::bookSectorHistos(int wheel,int sector,string hTag,string folder) {
00201
00202 stringstream wh; wh << wheel;
00203 stringstream sc; sc << sector;
00204 int sectorid = (wheel+3) + (sector-1)*5;
00205 bool isDCC = hwSource=="DCC" ;
00206 string basedir = topFolder(isDCC)+"Wheel"+wh.str()+"/Sector"+sc.str()+"/";
00207 if (folder!="") {
00208 basedir += folder +"/";
00209 }
00210 dbe->setCurrentFolder(basedir);
00211
00212 string fullTag = fullName(hTag);
00213 string hname = fullTag + "_W" + wh.str()+"_Sec" +sc.str();
00214 LogTrace(category()) << "[" << testName << "Test]: booking " << basedir << hname;
00215 if (hTag.find("BXDistribPhi") != string::npos){
00216 MonitorElement* me = dbe->book2D(hname.c_str(),hname.c_str(),25,-4.5,20.5,4,0.5,4.5);
00217 me->setBinLabel(1,"MB1",2);
00218 me->setBinLabel(2,"MB2",2);
00219 me->setBinLabel(3,"MB3",2);
00220 me->setBinLabel(4,"MB4",2);
00221 secME[sectorid][fullTag] = me;
00222 return;
00223 }
00224 else if (hTag.find("QualDistribPhi") != string::npos){
00225 MonitorElement* me = dbe->book2D(hname.c_str(),hname.c_str(),7,-0.5,6.5,4,0.5,4.5);
00226 me->setBinLabel(1,"MB1",2);
00227 me->setBinLabel(2,"MB2",2);
00228 me->setBinLabel(3,"MB3",2);
00229 me->setBinLabel(4,"MB4",2);
00230 me->setBinLabel(1,"LI",1);
00231 me->setBinLabel(2,"LO",1);
00232 me->setBinLabel(3,"HI",1);
00233 me->setBinLabel(4,"HO",1);
00234 me->setBinLabel(5,"LL",1);
00235 me->setBinLabel(6,"HL",1);
00236 me->setBinLabel(7,"HH",1);
00237 secME[sectorid][fullTag] = me;
00238 return;
00239 }
00240 else if (hTag.find("Phi") != string::npos ||
00241 hTag.find("TkvsTrig") != string::npos ){
00242 MonitorElement* me = dbe->book1D(hname.c_str(),hname.c_str(),4,0.5,4.5);
00243 me->setBinLabel(1,"MB1",1);
00244 me->setBinLabel(2,"MB2",1);
00245 me->setBinLabel(3,"MB3",1);
00246 me->setBinLabel(4,"MB4",1);
00247 secME[sectorid][fullTag] = me;
00248 return;
00249 }
00250
00251 if (hTag.find("Theta") != string::npos){
00252 MonitorElement* me =dbe->book1D(hname.c_str(),hname.c_str(),3,0.5,3.5);
00253 me->setBinLabel(1,"MB1",1);
00254 me->setBinLabel(2,"MB2",1);
00255 me->setBinLabel(3,"MB3",1);
00256 secME[sectorid][fullTag] = me;
00257 return;
00258 }
00259
00260 }
00261
00262 void DTLocalTriggerBaseTest::bookCmsHistos(string hTag,string folder) {
00263
00264 bool isDCC = hwSource == "DCC";
00265 string basedir = topFolder(isDCC);
00266 if (folder != "") {
00267 basedir += folder +"/" ;
00268 }
00269 dbe->setCurrentFolder(basedir);
00270
00271 string hname = fullName(hTag);
00272 LogTrace(category()) << "[" << testName << "Test]: booking " << basedir << hname;
00273
00274
00275 MonitorElement* me = dbe->book2D(hname.c_str(),hname.c_str(),12,1,13,5,-2,3);
00276 me->setAxisTitle("Sector",1);
00277 me->setAxisTitle("Wheel",2);
00278 cmsME[hname] = me;
00279
00280 }
00281
00282 void DTLocalTriggerBaseTest::bookWheelHistos(int wheel,string hTag,string folder) {
00283
00284 stringstream wh; wh << wheel;
00285 string basedir;
00286 bool isDCC = hwSource=="DCC" ;
00287 if (hTag.find("Summary") != string::npos ) {
00288 basedir = topFolder(isDCC);
00289 } else {
00290 basedir = topFolder(isDCC) + "Wheel" + wh.str() + "/" ;
00291
00292 }
00293 if (folder != "") {
00294 basedir += folder +"/" ;
00295 }
00296 dbe->setCurrentFolder(basedir);
00297
00298 string fullTag = fullName(hTag);
00299 string hname = fullTag+ "_W" + wh.str();
00300
00301 LogTrace(category()) << "[" << testName << "Test]: booking "<< basedir << hname;
00302
00303 if (hTag.find("Phi")!= string::npos ||
00304 hTag.find("Summary") != string::npos ){
00305 MonitorElement* me = dbe->book2D(hname.c_str(),hname.c_str(),12,1,13,4,1,5);
00306
00307
00308 me->setBinLabel(1,"MB1",2);
00309 me->setBinLabel(2,"MB2",2);
00310 me->setBinLabel(3,"MB3",2);
00311 me->setBinLabel(4,"MB4",2);
00312 me->setAxisTitle("Sector",1);
00313
00314 whME[wheel][fullTag] = me;
00315 return;
00316 }
00317
00318 if (hTag.find("Theta") != string::npos){
00319 MonitorElement* me =dbe->book2D(hname.c_str(),hname.c_str(),12,1,13,3,1,4);
00320
00321
00322 me->setBinLabel(1,"MB1",2);
00323 me->setBinLabel(2,"MB2",2);
00324 me->setBinLabel(3,"MB3",2);
00325 me->setAxisTitle("Sector",1);
00326
00327 whME[wheel][fullTag] = me;
00328 return;
00329 }
00330
00331 }
00332
00333 pair<float,float> DTLocalTriggerBaseTest::phiRange(const DTChamberId& id){
00334
00335 float min,max;
00336 int station = id.station();
00337 int sector = id.sector();
00338 int wheel = id.wheel();
00339
00340 const DTLayer *layer = muonGeom->layer(DTLayerId(id,1,1));
00341 DTTopology topo = layer->specificTopology();
00342 min = topo.wirePosition(topo.firstChannel());
00343 max = topo.wirePosition(topo.lastChannel());
00344
00345 if (station == 4){
00346
00347 const DTLayer *layer2;
00348 float lposx;
00349
00350 if (sector == 4){
00351 layer2 = muonGeom->layer(DTLayerId(wheel,station,13,1,1));
00352 lposx = layer->toLocal(layer2->position()).x();
00353 }
00354 else if (sector == 10){
00355 layer2 = muonGeom->layer(DTLayerId(wheel,station,14,1,1));
00356 lposx = layer->toLocal(layer2->position()).x();
00357 }
00358 else
00359 return make_pair(min,max);
00360
00361 DTTopology topo2 = layer2->specificTopology();
00362
00363 if (lposx>0){
00364 max = lposx*.5+topo2.wirePosition(topo2.lastChannel());
00365 min -= lposx*.5;
00366 }
00367 else{
00368 min = lposx*.5+topo2.wirePosition(topo2.firstChannel());
00369 max -= lposx*.5;
00370 }
00371
00372 }
00373
00374 return make_pair(min,max);
00375
00376 }