CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQM/RPCMonitorClient/src/RPCMultiplicityTest.cc

Go to the documentation of this file.
00001 /*
00002  *  \author Anna Cimmino
00003  */
00004 #include "DQM/RPCMonitorDigi/interface/utils.h"
00005 #include <DQM/RPCMonitorClient/interface/RPCMultiplicityTest.h>
00006 
00007 // Framework
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 //DQMServices
00010 # include "DQMServices/Core/interface/DQMNet.h"
00011 // Geometry
00012 #include "Geometry/RPCGeometry/interface/RPCGeomServ.h"
00013 
00014 #include <sstream>
00015 
00016 RPCMultiplicityTest::RPCMultiplicityTest(const edm::ParameterSet& ps ){
00017   edm::LogVerbatim ("multiplicity") << "[RPCMultiplicityTest]: Constructor";
00018   useRollInfo_ = ps.getUntrackedParameter<bool>("UseRollInfo", false);
00019   prescaleFactor_ = ps.getUntrackedParameter<int>("DiagnosticPrescale", 1);
00020   numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 3);
00021   numberOfRings_ = ps.getUntrackedParameter<int>("NumberOfEndcapRings", 2);
00022   testMode_ = ps.getUntrackedParameter<bool>("testMode", false);
00023 }
00024 
00025 RPCMultiplicityTest::~RPCMultiplicityTest(){
00026   dbe_ = 0;
00027 }
00028 
00029 
00030 void RPCMultiplicityTest::beginJob(DQMStore *  dbe, std::string workingFolder ){
00031  edm::LogVerbatim ("multiplicity") << "[RPCMultiplicityTest]: Begin job";
00032 
00033  globalFolder_ =  workingFolder;
00034  dbe_=dbe;
00035 }
00036 
00037 
00038 void RPCMultiplicityTest::endRun(const edm::Run& r, const edm::EventSetup& iSetup){
00039 
00040   edm::LogVerbatim ("multiplicity") << "[RPCMultiplicityTest]: End run";
00041   
00042 }
00043  
00044 void RPCMultiplicityTest::getMonitorElements(std::vector<MonitorElement *> & meVector, std::vector<RPCDetId> &  detIdVector){
00045 
00046   //Get NumberOfDigi ME for each roll
00047   for (unsigned int i = 0 ; i<meVector.size(); i++){
00048     
00049     bool flag= false;
00050     
00051     DQMNet::TagList tagList;
00052     tagList = meVector[i]->getTags();
00053     DQMNet::TagList::iterator tagItr = tagList.begin();
00054     
00055     while (tagItr != tagList.end() && !flag ) {
00056       if((*tagItr) ==  rpcdqm::MULTIPLICITY)
00057         flag= true;
00058       
00059       tagItr++;
00060     }
00061     
00062     if(flag){
00063       myNumDigiMe_.push_back(meVector[i]);
00064       myDetIds_.push_back(detIdVector[i]);
00065     }
00066   }
00067 }
00068 
00069 
00070 void RPCMultiplicityTest::beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& context) {}
00071 
00072 void RPCMultiplicityTest::analyze(const edm::Event& iEvent, const edm::EventSetup& c){}
00073 
00074 void RPCMultiplicityTest::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& iSetup) {}
00075 
00076 void RPCMultiplicityTest::clientOperation(edm::EventSetup const& iSetup) {
00077 
00078   edm::LogVerbatim ("multiplicity") <<"[RPCMultiplicityTest]: Client Operation";
00079  
00080   //Loop on MEs
00081   for (unsigned int  i = 0 ; i<myNumDigiMe_.size();i++){
00082     this->fillGlobalME(myDetIds_[i],myNumDigiMe_[i]);
00083   }//End loop on MEs
00084 }
00085  
00086 void RPCMultiplicityTest::beginRun(const edm::Run& r, const edm::EventSetup& c){
00087 
00088   MonitorElement* me=NULL;
00089   dbe_->setCurrentFolder(globalFolder_);
00090   
00091   std::stringstream histoName;
00092   
00093   rpcdqm::utils rpcUtils;
00094   
00095   for (int i = -2; i<=2;i++ ){//loop on wheels and disks
00096  
00097     histoName.str("");
00098     histoName<<"NumberOfDigi_Mean_Roll_vs_Sector_Wheel"<<i;
00099     me = 0;
00100     me = dbe_->get(globalFolder_ +"/"+ histoName.str());
00101     if ( 0!=me) {
00102       dbe_->removeElement(me->getName());
00103     }
00104     
00105     MULTWheel[i+2] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
00106     
00107     rpcUtils.labelXAxisSector( MULTWheel[i+2]);
00108     rpcUtils.labelYAxisRoll( MULTWheel[i+2], 0, i,useRollInfo_ );
00109     
00110     if(testMode_){
00111       histoName.str("");
00112       histoName<<"NumberOfDigi_Mean_Distribution_Wheel"<<i;
00113       me = 0;
00114       me = dbe_->get(globalFolder_ +"/"+ histoName.str());
00115       if ( 0!=me) {
00116         dbe_->removeElement(me->getName());
00117       }
00118       
00119       MULTDWheel[i+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.5, 50.5);
00120     }
00121     
00122   }//end wheels
00123 
00124   for(int d = -numberOfDisks_; d<=numberOfDisks_; d++ ){  
00125     if (d == 0 )continue;
00126     
00127     int offset = numberOfDisks_;
00128     if (d>0) offset --; //used to skip case equale to zero
00129     
00130     histoName.str("");
00131     histoName<<"NumberOfDigi_Mean_Ring_vs_Segment_Disk"<<d;
00132     me = 0;
00133     me = dbe_->get(globalFolder_ +"/"+ histoName.str());
00134     if ( 0!=me) {
00135       dbe_->removeElement(me->getName());
00136     }
00137     MULTDisk[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);
00138     rpcUtils.labelXAxisSegment(MULTDisk[d+offset]);
00139     rpcUtils.labelYAxisRing(MULTDisk[d+offset], numberOfRings_,useRollInfo_ );
00140     
00141     if(testMode_){
00142       histoName.str("");
00143       histoName<<"NumberOfDigi_Mean_Distribution_Disk"<<d;
00144       me = 0;
00145       me = dbe_->get(globalFolder_ +"/"+ histoName.str());
00146       if ( 0!=me) {
00147         dbe_->removeElement(me->getName());
00148       }
00149       
00150       MULTDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.5, 50.5);
00151     }
00152   }//end loop on wheels and disks
00153 
00154 
00155 }
00156 
00157  void RPCMultiplicityTest::endJob(){}
00158 
00159 void  RPCMultiplicityTest::fillGlobalME(RPCDetId & detId, MonitorElement * myMe){
00160 
00161   MonitorElement * MULT =NULL;
00162   MonitorElement * MULTD = NULL;
00163 
00164   if (detId.region()==0) {
00165     MULT = MULTWheel[detId.ring()+2];
00166     if(testMode_)   MULTD = MULTDWheel[detId.ring()+2];
00167   }else{
00168     if(-detId.station() + numberOfDisks_ >= 0 ){
00169     
00170       if(detId.region()<0){
00171       MULT = MULTDisk[-detId.station() + numberOfDisks_];
00172       if(testMode_)    MULTD = MULTDDisk[-detId.station()+ numberOfDisks_];
00173       }else{
00174         MULT = MULTDisk[detId.station()+ numberOfDisks_ -1];
00175    if(testMode_)        MULTD = MULTDDisk[detId.station()+ numberOfDisks_-1];
00176       }
00177     }
00178   }
00179 
00180 
00181     
00182     int xBin,yBin;
00183     if(detId.region()==0){//Barrel
00184       xBin= detId.sector();
00185       rpcdqm::utils rollNumber;
00186       yBin = rollNumber.detId2RollNr(detId);
00187     }else{//Endcap
00188       //get segment number
00189       RPCGeomServ RPCServ(detId);
00190       xBin = RPCServ.segment();
00191       (numberOfRings_ == 3 ? yBin= detId.ring()*3-detId.roll()+1 : yBin= (detId.ring()-1)*3-detId.roll()+1);
00192     }
00193     
00194     float mean = myMe->getMean();
00195     
00196     if(MULT)  MULT->setBinContent(xBin,yBin, mean );
00197     if(testMode_ && MULTD) MULTD->Fill(mean);
00198 
00199   
00200   
00201 }