00001
00002
00003 #include <sstream>
00004 #include <DQM/RPCMonitorClient/interface/RPCOccupancyTest.h>
00005 #include "DQM/RPCMonitorDigi/interface/utils.h"
00006
00007
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009
00010 #include "Geometry/RPCGeometry/interface/RPCGeomServ.h"
00011
00012 RPCOccupancyTest::RPCOccupancyTest(const edm::ParameterSet& ps ){
00013 edm::LogVerbatim ("rpceventsummary") << "[RPCOccupancyTest]: Constructor";
00014
00015 prescaleFactor_ = ps.getUntrackedParameter<int>("DiagnosticPrescale", 1);
00016 numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 3);
00017 numberOfRings_ = ps.getUntrackedParameter<int>("NumberOfEndcapRings", 2);
00018 testMode_ = ps.getUntrackedParameter<bool>("testMode", false);
00019 useRollInfo_ = ps.getUntrackedParameter<bool>("useRollInfo_", false);
00020
00021 std::string subsystemFolder = ps.getUntrackedParameter<std::string>("RPCFolder", "RPC");
00022 std::string recHitTypeFolder= ps.getUntrackedParameter<std::string>("RecHitTypeFolder", "AllHits");
00023
00024 prefixDir_ = subsystemFolder+ "/"+ recHitTypeFolder;
00025
00026 }
00027
00028 RPCOccupancyTest::~RPCOccupancyTest(){
00029 dbe_=0;
00030 }
00031
00032 void RPCOccupancyTest::beginJob(DQMStore * dbe, std::string workingFolder){
00033 edm::LogVerbatim ("rpceventsummary") << "[RPCOccupancyTest]: Begin job ";
00034 globalFolder_ = workingFolder;
00035 dbe_=dbe;
00036 }
00037
00038 void RPCOccupancyTest::endRun(const edm::Run& r, const edm::EventSetup& c){
00039 edm::LogVerbatim ("rpceventsummary") << "[RPCOccupancyTest]: End run";
00040 }
00041
00042 void RPCOccupancyTest::getMonitorElements(std::vector<MonitorElement *> & meVector, std::vector<RPCDetId> & detIdVector){
00043
00044
00045 for (unsigned int i = 0 ; i<meVector.size(); i++){
00046
00047 bool flag= false;
00048
00049 DQMNet::TagList tagList;
00050 tagList = meVector[i]->getTags();
00051 DQMNet::TagList::iterator tagItr = tagList.begin();
00052
00053 while (tagItr != tagList.end() && !flag ) {
00054 if((*tagItr) == rpcdqm::OCCUPANCY)
00055 flag= true;
00056 tagItr++;
00057 }
00058
00059 if(flag){
00060 myOccupancyMe_.push_back(meVector[i]);
00061 myDetIds_.push_back(detIdVector[i]);
00062 }
00063 }
00064 }
00065
00066 void RPCOccupancyTest::beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& context){}
00067
00068 void RPCOccupancyTest::analyze(const edm::Event& iEvent, const edm::EventSetup& c) {}
00069
00070 void RPCOccupancyTest::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& iSetup) {}
00071
00072 void RPCOccupancyTest::clientOperation(edm::EventSetup const& iSetup) {
00073
00074 edm::LogVerbatim ("rpceventsummary") <<"[RPCOccupancyTest]: Client Operation";
00075
00076 MonitorElement * RPCEvents = dbe_->get(prefixDir_ +"/RPCEvents");
00077 if(RPCEvents == 0 ){rpcevents_ = 0;}
00078 else{
00079 rpcevents_ = RPCEvents ->getBinContent(1);
00080 }
00081
00082
00083 for (unsigned int i = 0 ; i<myOccupancyMe_.size();i++){
00084 this->fillGlobalME(myDetIds_[i],myOccupancyMe_[i]);
00085 }
00086 }
00087
00088 void RPCOccupancyTest::endJob(void) {}
00089 void RPCOccupancyTest::beginRun(const edm:: Run& r, const edm::EventSetup& c) {
00090
00091 MonitorElement* me;
00092 dbe_->setCurrentFolder( globalFolder_);
00093
00094 std::stringstream histoName;
00095 rpcdqm::utils rpcUtils;
00096
00097 histoName.str("");
00098 histoName<<"Barrel_OccupancyByStations_Normalized";
00099 me = dbe_->get( globalFolder_+"/"+ histoName.str());
00100 if ( 0!=me ) {
00101 dbe_->removeElement(me->getName());
00102 }
00103 Barrel_OccBySt = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 4, 0.5, 4.5);
00104 Barrel_OccBySt -> setBinLabel(1, "St1", 1);
00105 Barrel_OccBySt -> setBinLabel(2, "St2", 1);
00106 Barrel_OccBySt -> setBinLabel(3, "St3", 1);
00107 Barrel_OccBySt -> setBinLabel(4, "St4", 1);
00108
00109
00110 histoName.str("");
00111 histoName<<"EndCap_OccupancyByRings_Normalized";
00112 me = dbe_->get( globalFolder_+"/"+ histoName.str());
00113 if ( 0!=me ) {
00114 dbe_->removeElement(me->getName());
00115 }
00116 EndCap_OccByRng = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 4, 0.5, 4.5);
00117 EndCap_OccByRng -> setBinLabel(1, "E+/R3", 1);
00118 EndCap_OccByRng -> setBinLabel(2, "E+/R2", 1);
00119 EndCap_OccByRng -> setBinLabel(3, "E-/R2", 1);
00120 EndCap_OccByRng -> setBinLabel(4, "E-/R3", 1);
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 for (int w = -2; w<=2; w++ ){
00144
00145 histoName.str("");
00146 histoName<<"AsymmetryLeftRight_Roll_vs_Sector_Wheel"<<w;
00147 me = 0;
00148 me = dbe_->get( globalFolder_+"/"+ histoName.str());
00149 if ( 0!=me ) {
00150 dbe_->removeElement(me->getName());
00151 }
00152
00153 AsyMeWheel[w+2] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
00154
00155 rpcUtils.labelXAxisSector(AsyMeWheel[w+2]);
00156 rpcUtils.labelYAxisRoll(AsyMeWheel[w+2], 0, w, useRollInfo_);
00157
00158
00159 if(testMode_){
00160
00161 histoName.str("");
00162 histoName<<"OccupancyNormByEvents_Wheel"<<w;
00163 me = 0;
00164 me = dbe_->get( globalFolder_+"/"+ histoName.str());
00165 if ( 0!=me ) {
00166 dbe_->removeElement(me->getName());
00167 }
00168
00169 NormOccupWheel[w+2] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
00170
00171 rpcUtils.labelXAxisSector( NormOccupWheel[w+2]);
00172 rpcUtils.labelYAxisRoll( NormOccupWheel[w+2], 0, w, useRollInfo_);
00173
00174
00175 histoName.str("");
00176 histoName<<"AsymmetryLeftRight_Distribution_Wheel"<<w;
00177 me = 0;
00178 me = dbe_->get( globalFolder_+"/"+ histoName.str());
00179 if ( 0!=me ) {
00180 dbe_->removeElement(me->getName());
00181 }
00182 AsyMeDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 20, -0.1, 1.1);
00183
00184 histoName.str("");
00185 histoName<<"OccupancyNormByEvents_Distribution_Wheel"<<w;
00186 me = 0;
00187 me = dbe_->get( globalFolder_+"/"+ histoName.str());
00188 if ( 0!=me ) {
00189 dbe_->removeElement(me->getName());
00190 }
00191 NormOccupDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.0, 0.205);
00192 }
00193 }
00194
00195 for(int d = -numberOfDisks_; d<=numberOfDisks_; d++ ){
00196
00197 if (d == 0)continue;
00198
00199 int offset = numberOfDisks_;
00200 if (d>0) offset --;
00201
00202 histoName.str("");
00203 histoName<<"AsymmetryLeftRight_Ring_vs_Segment_Disk"<<d;
00204 me = 0;
00205 me = dbe_->get( globalFolder_+"/"+ histoName.str());
00206 if ( 0!=me ) {
00207 dbe_->removeElement(me->getName());
00208 }
00209
00210 AsyMeDisk[d+offset] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 36, 0.5, 36.5, 3*numberOfRings_, 0.5,3*numberOfRings_+ 0.5);
00211
00212 rpcUtils.labelXAxisSegment(AsyMeDisk[d+offset]);
00213 rpcUtils.labelYAxisRing(AsyMeDisk[d+offset], numberOfRings_, useRollInfo_);
00214
00215
00216
00217 if(testMode_){
00218
00219 histoName.str("");
00220 histoName<<"OccupancyNormByEvents_Disk"<<d;
00221 me = 0;
00222 me = dbe_->get( globalFolder_+"/"+ histoName.str());
00223 if ( 0!=me ) {
00224 dbe_->removeElement(me->getName());
00225 }
00226
00227 NormOccupDisk[d+offset] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 36, 0.5, 36.5, 3*numberOfRings_, 0.5,3*numberOfRings_+ 0.5);
00228
00229 rpcUtils.labelXAxisSegment(NormOccupDisk[d+offset]);
00230 rpcUtils.labelYAxisRing( NormOccupDisk[d+offset],numberOfRings_, useRollInfo_);
00231
00232 histoName.str("");
00233 histoName<<"AsymmetryLeftRight_Distribution_Disk"<<d;
00234 me = 0;
00235 me = dbe_->get( globalFolder_+"/"+ histoName.str());
00236 if ( 0!=me ) {
00237 dbe_->removeElement(me->getName());
00238 }
00239 AsyMeDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 20, -0.1, 1.1);
00240
00241
00242
00243 histoName.str("");
00244 histoName<<"OccupancyNormByEvents_Distribution_Disk"<<d;
00245 me = 0;
00246 me = dbe_->get( globalFolder_+"/"+ histoName.str());
00247 if ( 0!=me ) {
00248 dbe_->removeElement(me->getName());
00249 }
00250 NormOccupDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.0, 0.205);
00251 }
00252 }
00253 }
00254
00255
00256 void RPCOccupancyTest::fillGlobalME(RPCDetId & detId, MonitorElement * myMe){
00257
00258
00259 if (!myMe) return;
00260
00261 MonitorElement * AsyMe=NULL;
00262 MonitorElement * AsyMeD=NULL;
00263 MonitorElement * NormOccup=NULL;
00264 MonitorElement * NormOccupD=NULL;
00265
00266 if(detId.region() ==0){
00267 AsyMe= AsyMeWheel[detId.ring()+2];
00268 if(testMode_){
00269 NormOccup=NormOccupWheel[detId.ring()+2];
00270 AsyMeD= AsyMeDWheel[detId.ring()+2];
00271 NormOccupD=NormOccupDWheel[detId.ring()+2];
00272 }
00273
00274 }else{
00275
00276 if( -detId.station() + numberOfDisks_ >= 0 ){
00277
00278 if(detId.region()<0){
00279 AsyMe= AsyMeDisk[-detId.station() + numberOfDisks_];
00280 if(testMode_){
00281 NormOccup=NormOccupDisk[-detId.station() + numberOfDisks_];
00282 AsyMeD= AsyMeDDisk[-detId.station() + numberOfDisks_];
00283 NormOccupD=NormOccupDDisk[-detId.station() + numberOfDisks_];
00284 }
00285 }else{
00286 AsyMe= AsyMeDisk[detId.station() + numberOfDisks_-1];
00287 if(testMode_){
00288 NormOccup=NormOccupDisk[detId.station() + numberOfDisks_-1];
00289 AsyMeD= AsyMeDDisk[detId.station() + numberOfDisks_-1];
00290 NormOccupD=NormOccupDDisk[detId.station() + numberOfDisks_-1];
00291 }
00292 }
00293 }
00294 }
00295
00296
00297 int xBin,yBin;
00298 if(detId.region()==0){
00299 xBin= detId.sector();
00300 rpcdqm::utils rollNumber;
00301 yBin = rollNumber.detId2RollNr(detId);
00302 }else{
00303
00304 RPCGeomServ RPCServ(detId);
00305 xBin = RPCServ.segment();
00306 (numberOfRings_ == 3 ? yBin= detId.ring()*3-detId.roll()+1 : yBin= (detId.ring()-1)*3-detId.roll()+1);
00307 }
00308
00309
00310 int stripInRoll=myMe->getNbinsX();
00311 float FOccupancy=0;
00312 float BOccupancy=0;
00313
00314 float totEnt = myMe->getEntries();
00315 for(int strip = 1 ; strip<=stripInRoll; strip++){
00316 if(strip<=stripInRoll/2) FOccupancy+=myMe->getBinContent(strip);
00317 else BOccupancy+=myMe->getBinContent(strip);
00318 }
00319
00320
00321 float asym = 0;
00322 if(totEnt != 0 ) asym = fabs((FOccupancy - BOccupancy )/totEnt);
00323
00324 if(AsyMe) AsyMe->setBinContent(xBin,yBin,asym);
00325
00326
00327
00328 float normoccup = 1;
00329 if(rpcevents_ != 0) normoccup = (totEnt/rpcevents_);
00330
00331 if(testMode_){
00332 if(NormOccup) NormOccup->setBinContent(xBin,yBin, normoccup);
00333 if(AsyMeD) AsyMeD->Fill(asym);
00334 if(NormOccupD) NormOccupD->Fill(normoccup);
00335 }
00336
00337
00338 if(detId.region()==0) {
00339 if(Barrel_OccBySt)Barrel_OccBySt -> Fill(detId.station(), normoccup);
00340 }else if(detId.region()==1) {
00341 if(detId.ring()==3) {
00342 EndCap_OccByRng -> Fill(1, normoccup);
00343 } else {
00344 EndCap_OccByRng -> Fill(2, normoccup);
00345 }
00346 } else {
00347 if(detId.ring()==3) {
00348 EndCap_OccByRng -> Fill(4, normoccup);
00349 }else {
00350 EndCap_OccByRng -> Fill(3, normoccup);
00351 }
00352 }
00353
00354 }
00355
00356
00357
00358
00359