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