00001 #include <sstream>
00002 #include <TMath.h>
00003 #include "DQM/RPCMonitorDigi/interface/RPCRecHitProbability.h"
00005 #include "DataFormats/Scalers/interface/DcsStatus.h"
00006 #include "DataFormats/MuonReco/interface/Muon.h"
00007
00008 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00009 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00010
00011 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00012
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014
00015 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
00016
00017 RPCRecHitProbability::RPCRecHitProbability( const edm::ParameterSet& pset ):counter(0){
00018
00019 saveRootFile = pset.getUntrackedParameter<bool>("SaveRootFile", false);
00020 RootFileName = pset.getUntrackedParameter<std::string>("RootFileName", "RPCRecHitProbabilityDQM.root");
00021
00022 muonLabel_ = pset.getParameter<edm::InputTag>("MuonLabel");
00023 muPtCut_ = pset.getUntrackedParameter<double>("MuonPtCut", 3.0);
00024 muEtaCut_ = pset.getUntrackedParameter<double>("MuonEtaCut", 1.9);
00025
00026 subsystemFolder_ = pset.getUntrackedParameter<std::string>("RPCFolder", "RPC");
00027 globalFolder_ = pset.getUntrackedParameter<std::string>("GlobalFolder", "SummaryHistograms");
00028 muonFolder_ = pset.getUntrackedParameter<std::string>("MuonFolder", "Muon");
00029 }
00030
00031 RPCRecHitProbability::~RPCRecHitProbability(){}
00032 void RPCRecHitProbability::beginJob(){}
00033
00034 void RPCRecHitProbability::beginRun(const edm::Run& r, const edm::EventSetup& iSetup){
00035
00036 edm::LogInfo ("rpcrechitprobability") <<"[RPCRecHitProbability]: Begin Run " ;
00037
00039 dbe = edm::Service<DQMStore>().operator->();
00040
00041 std::string currentFolder = subsystemFolder_ +"/"+muonFolder_+"/"+ globalFolder_;
00042 dbe->setCurrentFolder(currentFolder);
00043
00044 int ptBins = 100 - (int)muPtCut_;
00045
00046
00047 NumberOfMuonEta_ = dbe->get(currentFolder+"/NumberOfMuonEta");
00048 if(NumberOfMuonEta_) dbe->removeElement(NumberOfMuonEta_->getName());
00049 NumberOfMuonEta_ = dbe->book1D("NumberOfMuonEta", "Muons vs Eta", 20*muEtaCut_, -muEtaCut_, muEtaCut_ );
00050
00051 NumberOfMuonPt_B_ = dbe->get(currentFolder+"/NumberOfMuonPt_Barrel");
00052 if(NumberOfMuonPt_B_) dbe->removeElement(NumberOfMuonPt_B_->getName());
00053 NumberOfMuonPt_B_ = dbe->book1D("NumberOfMuonPt_Barrel", "Muons vs Pt - Barrel", ptBins, muPtCut_, 100);
00054
00055 NumberOfMuonPt_EP_ = dbe->get(currentFolder+"/NumberOfMuonPt_EndcapP");
00056 if(NumberOfMuonPt_EP_) dbe->removeElement(NumberOfMuonPt_EP_->getName());
00057 NumberOfMuonPt_EP_ = dbe->book1D("NumberOfMuonPt_EndcapP", "Muons vs Pt - Endcap+", ptBins , muPtCut_ , 100);
00058
00059 NumberOfMuonPt_EM_ = dbe->get(currentFolder+"/NumberOfMuonPt_EndcapM");
00060 if(NumberOfMuonPt_EM_) dbe->removeElement(NumberOfMuonPt_EM_->getName());
00061 NumberOfMuonPt_EM_ = dbe->book1D("NumberOfMuonPt_EndcapM", "Muons vs Pt - Endcap-", ptBins , muPtCut_ , 100);
00062
00063 NumberOfMuonPhi_B_ = dbe->get(currentFolder+"/NumberOfMuonPhi_Barrel");
00064 if(NumberOfMuonPhi_B_) dbe->removeElement(NumberOfMuonPhi_B_->getName());
00065 NumberOfMuonPhi_B_ = dbe->book1D("NumberOfMuonPhi_Barrel", "Muons vs Phi - Barrel", 144, -TMath::Pi(), TMath::Pi());
00066
00067 NumberOfMuonPhi_EP_ = dbe->get(currentFolder+"/NumberOfMuonPhi_EndcapP");
00068 if(NumberOfMuonPhi_EP_) dbe->removeElement(NumberOfMuonPhi_EP_->getName());
00069 NumberOfMuonPhi_EP_ = dbe->book1D("NumberOfMuonPhi_EndcapP", "Muons vs Phi - Endcap+", 144, -TMath::Pi(), TMath::Pi() );
00070
00071 NumberOfMuonPhi_EM_ = dbe->get(currentFolder+"/NumberOfMuonPhi_EndcapM");
00072 if(NumberOfMuonPhi_EM_) dbe->removeElement(NumberOfMuonPhi_EM_->getName());
00073 NumberOfMuonPhi_EM_ = dbe->book1D("NumberOfMuonPhi_EndcapM", "Muons vs Phi - Endcap-", 144, -TMath::Pi(), TMath::Pi());
00074
00075
00076 RPCRecHitMuonEta_ = dbe->get(currentFolder+"/RPCRecHitMuonEta");
00077 if(RPCRecHitMuonEta_) dbe->removeElement(RPCRecHitMuonEta_->getName());
00078 RPCRecHitMuonEta_ = dbe->book2D("RPCRecHitMuonEta", "Number Of RecHits per Muons vs Eta", 20*muEtaCut_, -muEtaCut_, muEtaCut_, 7, 0.5, 7.5);
00079
00080 std::stringstream name, title;
00081 for(int i = 0 ; i< 6 ; i++) {
00082 name.str("");
00083 title.str("");
00084 name<<(i+1)<<"RecHitMuonEta";
00085 title<<"At least " <<(i+1)<<" Cluster vs Eta";
00086 recHitEta_[i] = dbe->book1D(name.str(), title.str(), 20*muEtaCut_, -muEtaCut_, muEtaCut_);
00087
00088 name.str("");
00089 title.str("");
00090 name<<(i+1)<<"RecHitMuonPhiB";
00091 title<<"At least " <<(i+1)<<" Cluster vs Phi-Barrel";
00092 recHitPhi_B_[i] = dbe->book1D(name.str(), title.str(), 144, -TMath::Pi(), TMath::Pi());
00093
00094 name.str("");
00095 title.str("");
00096 name<<(i+1)<<"RecHitMuonPtB";
00097 title<<"At least " <<(i+1)<<" Cluster vs Pt-Barrel";
00098 recHitPt_B_[i] = dbe->book1D(name.str(), title.str(), ptBins , muPtCut_ , 100);
00099
00100 name.str("");
00101 title.str("");
00102 name<<(i+1)<<"RecHitMuonPhiEP";
00103 title<<"At least " <<(i+1)<<" Cluster vs Phi-Endcap+";
00104 recHitPhi_EP_[i] = dbe->book1D(name.str(), title.str(), 144, -TMath::Pi(), TMath::Pi() );
00105
00106 name.str("");
00107 title.str("");
00108 name<<(i+1)<<"RecHitMuonPtEP";
00109 title<<"At least " <<(i+1)<<" Cluster vs Pt-Endcap+";
00110 recHitPt_EP_[i] = dbe->book1D(name.str(), title.str(), ptBins , muPtCut_ , 100);
00111
00112 name.str("");
00113 title.str("");
00114 name<<(i+1)<<"RecHitMuonPhiEM";
00115 title<<"At least " <<(i+1)<<" Cluster vs Phi-Endcap-";
00116 recHitPhi_EM_[i] = dbe->book1D(name.str(), title.str(), 144, -TMath::Pi(), TMath::Pi());
00117
00118 name.str("");
00119 title.str("");
00120 name<<(i+1)<<"RecHitMuonPtEM";
00121 title<<"At least " <<(i+1)<<" Cluster vs Pt-Endcap-";
00122 recHitPt_EM_[i] = dbe->book1D(name.str(), title.str(), ptBins , muPtCut_ , 100);
00123
00124 }
00125
00126 dcs_ = true;
00127 }
00128
00129 void RPCRecHitProbability::endJob(void){
00130 if(saveRootFile) dbe->save(RootFileName);
00131 dbe = 0;
00132 }
00133
00134 void RPCRecHitProbability::endLuminosityBlock(edm::LuminosityBlock const& L, edm::EventSetup const& E){}
00135
00136
00137 void RPCRecHitProbability::analyze(const edm::Event& event,const edm::EventSetup& setup ){
00138 dcs_ = true;
00139
00140 this->makeDcsInfo(event);
00141 if( !dcs_){
00142 edm::LogWarning ("rpcrechitprobability") <<"[RPCRecHitProbability]: DCS bit OFF" ;
00143 return;
00144 }
00145
00146 counter++;
00147 edm::LogInfo ("rpcrechitprobability") <<"[RPCRecHitProbability]: Beginning analyzing event " << counter;
00148
00149
00150 edm::Handle<reco::CandidateView> muonCands;
00151 event.getByLabel(muonLabel_, muonCands);
00152 std::map<RPCDetId , std::vector<RPCRecHit> > rechitMuon;
00153
00154 if(muonCands.isValid()){
00155
00156 int nStaMuons = muonCands->size();
00157
00158 for( int i = 0; i < nStaMuons; i++ ) {
00159
00160 const reco::Candidate & goodMuon = (*muonCands)[i];
00161 const reco::Muon * muCand = dynamic_cast<const reco::Muon*>(&goodMuon);
00162
00163 if(!muCand->isGlobalMuon())continue;
00164 float eta = muCand->eta();
00165 float pt = muCand->pt();
00166 if( pt < muPtCut_ || fabs(eta)>muEtaCut_) continue;
00167
00168 float phi = muCand->phi();
00169
00170 NumberOfMuonEta_ -> Fill(eta);
00171
00172 if(eta > 0.8){
00173 NumberOfMuonPt_EP_ -> Fill(pt);
00174 NumberOfMuonPhi_EP_ -> Fill(phi);
00175 }else if (eta < -0.8){
00176 NumberOfMuonPt_EM_ -> Fill(pt);
00177 NumberOfMuonPhi_EM_ -> Fill(phi);
00178 }else{
00179 NumberOfMuonPt_B_ -> Fill(pt);
00180 NumberOfMuonPhi_B_ -> Fill(phi);
00181 }
00182
00183 reco::Track muTrack = (*(muCand->outerTrack()));
00184 std::vector<TrackingRecHitRef > rpcTrackRecHits;
00185
00186
00187
00188 int recHitCounter = 0;
00189 for ( trackingRecHit_iterator it= muTrack.recHitsBegin(); it != muTrack.recHitsEnd() ; it++) {
00190 if (!(*it)->isValid ()) continue;
00191 int muSubDetId = (*it)->geographicalId().subdetId();
00192 if(muSubDetId == MuonSubdetId::RPC) {
00193 recHitCounter ++;
00194 }
00195 }
00196
00197 RPCRecHitMuonEta_ -> Fill(eta, recHitCounter);
00198
00199 int j = 0;
00200 while (recHitCounter >= j+1 && j<6){
00201
00202 if(recHitEta_[j]) recHitEta_[j]->Fill(eta);
00203 if(eta > 0.8) {
00204 recHitPt_EP_[j] -> Fill(pt);
00205 recHitPhi_EP_[j] -> Fill(phi);
00206 }else if (eta < -0.8){
00207 recHitPt_EM_[j]-> Fill(pt);
00208 recHitPhi_EM_[j]-> Fill(phi);
00209 }else{
00210 recHitPt_B_[j]-> Fill(pt);
00211 recHitPhi_B_[j]-> Fill(phi);
00212 }
00213
00214 j++;
00215 }
00216
00217
00218 }
00219 }else{
00220 edm::LogError ("rpcrechitprobability") <<"[RPCRecHitProbability]: Muons - Product not valid for event" << counter;
00221 }
00222
00223 }
00224
00225 void RPCRecHitProbability::makeDcsInfo(const edm::Event& e) {
00226
00227 edm::Handle<DcsStatusCollection> dcsStatus;
00228
00229 if ( ! e.getByLabel("scalersRawToDigi", dcsStatus) ){
00230 dcs_ = true;
00231 return;
00232 }
00233
00234 if ( ! dcsStatus.isValid() )
00235 {
00236 edm::LogWarning("RPCDcsInfo") << "scalersRawToDigi not found" ;
00237 dcs_ = true;
00238 return;
00239 }
00240
00241 for (DcsStatusCollection::const_iterator dcsStatusItr = dcsStatus->begin();
00242 dcsStatusItr != dcsStatus->end(); ++dcsStatusItr){
00243
00244 if (!dcsStatusItr->ready(DcsStatus::RPC)) dcs_=false;
00245 }
00246
00247 return ;
00248 }
00249
00250