CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/DQM/RPCMonitorClient/src/RPCClusterSizeTest.cc

Go to the documentation of this file.
00001 #include <DQM/RPCMonitorClient/interface/RPCClusterSizeTest.h>
00002 #include "DQM/RPCMonitorDigi/interface/utils.h"
00003 
00004 // Framework
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 
00007 // //Geometry
00008 #include "Geometry/RPCGeometry/interface/RPCGeomServ.h"
00009 
00010 RPCClusterSizeTest::RPCClusterSizeTest(const edm::ParameterSet& ps ){
00011   edm::LogVerbatim ("rpceventsummary") << "[RPCClusterSizeTest]: Constructor";
00012   
00013   prescaleFactor_ =  ps.getUntrackedParameter<int>("DiagnosticPrescale", 1);
00014   
00015   numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 3);
00016   numberOfRings_ = ps.getUntrackedParameter<int>("NumberOfEndcapRings", 2);
00017   testMode_ = ps.getUntrackedParameter<bool>("testMode", false);
00018   useRollInfo_ = ps.getUntrackedParameter<bool>("useRollInfo", false);
00019 }
00020 
00021 RPCClusterSizeTest::~RPCClusterSizeTest(){ dbe_=0;}
00022 
00023 void RPCClusterSizeTest::beginJob(DQMStore *  dbe, std::string workingFolder){
00024   edm::LogVerbatim ("rpceventsummary") << "[RPCClusterSizeTest]: Begin job ";
00025 
00026   globalFolder_  = workingFolder;
00027   dbe_ = dbe;
00028 }
00029 
00030 void RPCClusterSizeTest::endRun(const edm::Run& r, const edm::EventSetup& c){
00031   edm::LogVerbatim ("rpceventsummary") << "[RPCClusterSizeTest]: End run";
00032 }
00033 
00034 void RPCClusterSizeTest::getMonitorElements(std::vector<MonitorElement *> & meVector, std::vector<RPCDetId> & detIdVector){
00035     
00036  
00037  //Get  ME for each roll
00038  for (unsigned int i = 0 ; i<meVector.size(); i++){
00039 
00040    bool flag= false;
00041    
00042    DQMNet::TagList tagList;
00043    tagList = meVector[i]->getTags();
00044    DQMNet::TagList::iterator tagItr = tagList.begin();
00045 
00046    while (tagItr != tagList.end() && !flag ) {
00047      if((*tagItr) ==  rpcdqm::CLUSTERSIZE)
00048        flag= true;
00049    
00050      tagItr++;
00051    }
00052    
00053    if(flag){
00054      myClusterMe_.push_back(meVector[i]);
00055      myDetIds_.push_back(detIdVector[i]);
00056    }
00057  }
00058 
00059 }
00060 
00061 void RPCClusterSizeTest::beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& context){} 
00062 
00063 void RPCClusterSizeTest::analyze(const edm::Event& iEvent, const edm::EventSetup& c) {}
00064 
00065 void RPCClusterSizeTest::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& iSetup) {} 
00066 
00067 void RPCClusterSizeTest::clientOperation(edm::EventSetup const& iSetup) {
00068   
00069   edm::LogVerbatim ("rpceventsummary") <<"[RPCClusterSizeTest]:Client Operation";
00070   
00071   //check some statements and prescale Factor
00072   if(myClusterMe_.size()==0 || myDetIds_.size()==0)return;
00073         
00074   MonitorElement * CLS =NULL;          // ClusterSize in 1 bin, Roll vs Sector
00075   MonitorElement * CLSD =NULL;         // ClusterSize in 1 bin, Distribution
00076   MonitorElement * MEAN =NULL;         // Mean ClusterSize, Roll vs Sector
00077   MonitorElement * MEAND =NULL;        // Mean ClusterSize, Distribution
00078   
00079   
00080   std::stringstream meName;
00081   RPCDetId detId;
00082   MonitorElement * myMe;
00083 
00084   
00085   //Loop on chambers
00086   for (unsigned int  i = 0 ; i<myClusterMe_.size();i++){
00087     
00088     myMe = myClusterMe_[i];
00089     if (!myMe || myMe->getEntries()==0 )continue;
00090 
00091     
00092     detId=myDetIds_[i];
00093     
00094     
00095     if (detId.region()==0){
00096 
00097       CLS=CLSWheel[detId.ring()+2];
00098       MEAN= MEANWheel[detId.ring()+2];
00099       if(testMode_){
00100         CLSD=CLSDWheel[detId.ring()+2];
00101         MEAND=MEANDWheel[detId.ring()+2];
00102       }
00103     }else {
00104       
00105       if(((detId.station() * detId.region() ) + numberOfDisks_) >= 0 ){
00106         
00107         if(detId.region()<0){
00108           CLS=CLSDisk[(detId.station() * detId.region() ) + numberOfDisks_];
00109           MEAN=  MEANDisk[(detId.station() * detId.region() ) + numberOfDisks_];
00110           if(testMode_){
00111             CLSD = CLSDDisk[(detId.station() * detId.region() ) + numberOfDisks_];
00112             MEAND= MEANDDisk[(detId.station() * detId.region() ) + numberOfDisks_];
00113           }
00114         }else{
00115           CLS=CLSDisk[(detId.station() * detId.region() ) + numberOfDisks_ -1];
00116           MEAN= MEANDisk[(detId.station() * detId.region() ) + numberOfDisks_-1];
00117           if(testMode_){
00118             CLSD = CLSDDisk[(detId.station() * detId.region() ) + numberOfDisks_-1];
00119             MEAND= MEANDDisk[(detId.station() * detId.region() ) + numberOfDisks_-1];
00120           }
00121         }
00122       }
00123       
00124     }
00125 
00126   
00127     int xBin,yBin;
00128     
00129     if (detId.region()==0){//Barrel
00130       
00131       rpcdqm::utils rollNumber;
00132       yBin = rollNumber.detId2RollNr(detId);
00133       xBin = detId.sector();
00134     }else {//Endcap
00135       
00136       //get segment number
00137       RPCGeomServ RPCServ(detId);
00138       xBin = RPCServ.segment();
00139       (numberOfRings_ == 3 ? yBin= detId.ring()*3-detId.roll()+1 : yBin= (detId.ring()-1)*3-detId.roll()+1);
00140     }
00141     
00142     // Normalization -> # of Entries in first Bin normalaized by total Entries
00143     
00144     float NormCLS = myMe->getBinContent(1)/myMe->getEntries();
00145     float meanCLS = myMe->getMean();
00146     
00147     if (CLS)  CLS -> setBinContent(xBin,yBin, NormCLS);
00148     if(MEAN)   MEAN -> setBinContent(xBin, yBin, meanCLS);
00149  
00150     if(testMode_){
00151       if(MEAND) MEAND->Fill(meanCLS);
00152       if(CLSD)   CLSD->Fill(NormCLS);
00153     }
00154     
00155   }//End loop on chambers
00156 } 
00157 
00158 void  RPCClusterSizeTest::endJob(void) {}
00159 void  RPCClusterSizeTest::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00160  MonitorElement* me;
00161   dbe_->setCurrentFolder(globalFolder_);
00162 
00163   std::stringstream histoName;
00164 
00165   rpcdqm::utils rpcUtils;
00166 
00167   
00168   for (int w = -2; w<=2;w++ ){//loop on wheels 
00169   
00170     histoName.str("");   
00171     histoName<<"ClusterSizeIn1Bin_Roll_vs_Sector_Wheel"<<w;       // ClusterSize in first bin norm. by Entries (2D Roll vs Sector)       
00172     me = 0;
00173     me = dbe_->get(globalFolder_ + histoName.str()) ;
00174     if ( 0!=me ) {
00175       dbe_->removeElement(me->getName());
00176     }
00177     
00178     CLSWheel[w+2] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(),  12, 0.5, 12.5, 21, 0.5, 21.5);
00179     rpcUtils.labelXAxisSector(  CLSWheel[w+2]);
00180     rpcUtils.labelYAxisRoll(   CLSWheel[w+2], 0, w ,useRollInfo_);
00181     
00182     
00183     histoName.str("");
00184     histoName<<"ClusterSizeMean_Roll_vs_Sector_Wheel"<<w;       // Avarage ClusterSize (2D Roll vs Sector)   
00185     me = 0;
00186     me = dbe_->get(globalFolder_ + histoName.str()) ;
00187     if ( 0!=me) {
00188       dbe_->removeElement(me->getName());
00189     }
00190     
00191     MEANWheel[w+2] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(),  12, 0.5, 12.5, 21, 0.5, 21.5);
00192     
00193     rpcUtils.labelXAxisSector(  MEANWheel[w+2]);
00194     rpcUtils.labelYAxisRoll(MEANWheel[w+2], 0, w,useRollInfo_ );
00195     
00196     if(testMode_){
00197       histoName.str("");
00198       histoName<<"ClusterSizeIn1Bin_Distribution_Wheel"<<w;       //  ClusterSize in first bin, distribution
00199       me = 0;
00200       me = dbe_->get(globalFolder_ + histoName.str()) ;
00201       if ( 0!=me ) {
00202         dbe_->removeElement(me->getName());
00203       }
00204       CLSDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(),  20, 0.0, 1.0);
00205       
00206       
00207       histoName.str("");
00208       histoName<<"ClusterSizeMean_Distribution_Wheel"<<w;       //  Avarage ClusterSize Distribution
00209       me = 0;
00210       me = dbe_->get(globalFolder_ + histoName.str()) ;
00211       if ( 0!=me){
00212         dbe_->removeElement(me->getName());
00213       }
00214       MEANDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(),  100, 0.5, 10.5);
00215     }
00216   }//end loop on wheels
00217 
00218 
00219   for(int d = -numberOfDisks_;  d<=numberOfDisks_; d++ ){
00220     if (d == 0 )continue;
00221   //Endcap
00222     int offset = numberOfDisks_;
00223     if (d>0) offset --;
00224 
00225     histoName.str("");   
00226     histoName<<"ClusterSizeIn1Bin_Ring_vs_Segment_Disk"<<d;       // ClusterSize in first bin norm. by Entries (2D Roll vs Sector)   
00227     me = 0;
00228     me = dbe_->get(globalFolder_ + histoName.str()) ;
00229     if ( 0!=me){
00230       dbe_->removeElement(me->getName());
00231     }
00232     
00233     CLSDisk[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); 
00234     rpcUtils.labelXAxisSegment(CLSDisk[d+offset]);
00235     rpcUtils.labelYAxisRing(CLSDisk[d+offset], numberOfRings_,useRollInfo_ );
00236    
00237     if(testMode_){
00238       histoName.str("");
00239       histoName<<"ClusterSizeIn1Bin_Distribution_Disk"<<d;       //  ClusterSize in first bin, distribution
00240       me = 0;
00241       me = dbe_->get(globalFolder_ + histoName.str()) ;
00242       if ( 0!=me){
00243         dbe_->removeElement(me->getName());
00244       }
00245       CLSDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(),  20, 0.0, 1.0);
00246       
00247       histoName.str("");
00248       histoName<<"ClusterSizeMean_Distribution_Disk"<<d;       //  Avarage ClusterSize Distribution
00249       me = 0;
00250       me = dbe_->get(globalFolder_ + histoName.str()) ;
00251       if ( 0!=me){
00252         dbe_->removeElement(me->getName());
00253       }
00254       MEANDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(),  100, 0.5, 10.5);
00255       
00256     }
00257     
00258     histoName.str("");
00259     histoName<<"ClusterSizeMean_Ring_vs_Segment_Disk"<<d;       // Avarage ClusterSize (2D Roll vs Sector)   
00260     me = 0;
00261     me = dbe_->get(globalFolder_ + histoName.str()) ;
00262     if ( 0!=me){
00263       dbe_->removeElement(me->getName());
00264     }
00265     
00266     MEANDisk[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);
00267     rpcUtils.labelXAxisSegment(MEANDisk[d+offset]);
00268     rpcUtils.labelYAxisRing(MEANDisk[d+offset], numberOfRings_ ,useRollInfo_);
00269  
00270  }
00271 
00272 
00273 
00274 }