CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQM/RPCMonitorClient/src/RPCDataCertification.cc

Go to the documentation of this file.
00001 #include "DQM/RPCMonitorClient/interface/RPCDataCertification.h"
00002 
00003 #include "FWCore/ServiceRegistry/interface/Service.h"
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005 #include "FWCore/Framework/interface/EventSetup.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 
00008 #include "DQMServices/Core/interface/DQMStore.h"
00009 #include "DQMServices/Core/interface/MonitorElement.h"
00010 //CondFormats
00011 #include "CondFormats/RunInfo/interface/RunInfo.h"
00012 #include "CondFormats/DataRecord/interface/RunSummaryRcd.h"
00013 
00014 
00015 RPCDataCertification::RPCDataCertification(const edm::ParameterSet& ps) {
00016 
00017  numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 3);
00018 
00019  FEDRange_.first  = ps.getUntrackedParameter<unsigned int>("MinimumRPCFEDId", 790);
00020  FEDRange_.second = ps.getUntrackedParameter<unsigned int>("MaximumRPCFEDId", 792);
00021  
00022  NumberOfFeds_ =FEDRange_.second -  FEDRange_.first +1;
00023 }
00024 
00025 RPCDataCertification::~RPCDataCertification() {}
00026 
00027 
00028 void RPCDataCertification::beginJob(){}
00029 
00030 
00031   void RPCDataCertification::beginRun(const edm::Run& r, const edm::EventSetup& setup){
00032  edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("RunInfoRcd"));
00033 
00034  int defaultValue = 1;
00035 
00036  if(0 != setup.find( recordKey ) ) {
00037     defaultValue = -1;
00038     //get fed summary information
00039     edm::ESHandle<RunInfo> sumFED;
00040     setup.get<RunInfoRcd>().get(sumFED);    
00041     std::vector<int> FedsInIds= sumFED->m_fed_in;   
00042     unsigned int f = 0;
00043     bool flag = false;
00044     while(!flag && f < FedsInIds.size()) {
00045       int fedID=FedsInIds[f];
00046       //make sure fed id is in allowed range  
00047       if(fedID>=FEDRange_.first && fedID<=FEDRange_.second) {
00048         defaultValue = 1;
00049         flag = true;
00050       } 
00051       f++;
00052     }   
00053   }   
00054 
00055 
00056   // get the DQMStore
00057  theDbe = edm::Service<DQMStore>().operator->();
00058   
00059   theDbe->setCurrentFolder("RPC/EventInfo");
00060   // global fraction
00061   totalCertFraction = theDbe->bookFloat("CertificationSummary");  
00062   totalCertFraction->Fill(defaultValue);
00063 
00064   CertMap_ = theDbe->book2D( "CertificationSummaryMap","RPC Certification Summary Map",15, -7.5, 7.5, 12, 0.5 ,12.5);
00065   
00066   //customize the 2d histo
00067   std::stringstream BinLabel;
00068   for (int i= 1 ; i<13; i++){
00069     BinLabel.str("");
00070     BinLabel<<"Sec"<<i;
00071     CertMap_->setBinLabel(i,BinLabel.str(),2);
00072   } 
00073 
00074   for(int i = -2 ; i <=2; i++){
00075     BinLabel.str("");
00076     BinLabel<<"Wheel"<<i;
00077     CertMap_->setBinLabel(i+8,BinLabel.str(),1);
00078   }
00079 
00080 
00081  for(int i = 1; i<=numberOfDisks_; i++){
00082     BinLabel.str("");
00083     BinLabel<<"Disk"<<i;
00084     CertMap_->setBinLabel((i+11),BinLabel.str(),1);
00085     BinLabel.str("");
00086     BinLabel<<"Disk"<<-i;
00087     CertMap_->setBinLabel((-i+5),BinLabel.str(),1);
00088   }
00089   //fill the histo with "1" --- just for the moment
00090   for(int i=1; i<=15; i++){
00091      for (int j=1; j<=12; j++ ){
00092        if(i==5 || i==11 || (j>6 && (i<6 || i>10)))    
00093          CertMap_->setBinContent(i,j,-1);//bins that not correspond to subdetector parts
00094        else
00095          CertMap_->setBinContent(i,j,defaultValue);
00096      }
00097    }
00098 
00099 
00100   if(numberOfDisks_ < 4){
00101     for (int j=1; j<=12; j++ ){
00102       CertMap_->setBinContent(1,j,-1);//bins that not correspond to subdetector parts
00103       CertMap_->setBinContent(15,j,-1);
00104     }
00105  }
00106   // book the ME
00107   theDbe->setCurrentFolder("RPC/EventInfo/CertificationContents");
00108 
00109   int limit = numberOfDisks_;
00110   if(numberOfDisks_ < 2) limit = 2;
00111   
00112 
00113   for (int i = -1 * limit; i<= limit;i++ ){//loop on wheels and disks
00114     if (i>-3 && i<3){//wheels
00115       std::stringstream streams;
00116       streams << "RPC_Wheel" << i;
00117       certWheelFractions[i+2] = theDbe->bookFloat(streams.str());
00118       certWheelFractions[i+2]->Fill(defaultValue);
00119    }
00120     
00121     if (i == 0  || i > numberOfDisks_ || i< (-1 * numberOfDisks_))continue;
00122     
00123     int offset = numberOfDisks_;
00124     if (i>0) offset --; //used to skip case equale to zero
00125     std::stringstream streams;
00126     streams << "RPC_Disk" << i;
00127     certDiskFractions[i+2] = theDbe->bookFloat(streams.str());
00128     certDiskFractions[i+2]->Fill(defaultValue);
00129   }
00130 }
00131 
00132 void RPCDataCertification::beginLuminosityBlock(const edm::LuminosityBlock& lumi, const  edm::EventSetup& setup) {}
00133 
00134 
00135 void RPCDataCertification::endLuminosityBlock(const edm::LuminosityBlock&  lumi, const  edm::EventSetup& setup){}
00136 
00137 
00138 void RPCDataCertification::endJob() {}
00139 
00140 
00141 
00142 void RPCDataCertification::analyze(const edm::Event& event, const edm::EventSetup& setup){}
00143 
00144 
00145 
00146 
00147