CMS 3D CMS Logo

RPCRecHitProbability.cc
Go to the documentation of this file.
1 #include <sstream>
2 #include <TMath.h>
4 //Geometry
7 //Tracking Tools
9 //FW Core
11 //Reco Muon
13 
15 
16  saveRootFile = pset.getUntrackedParameter<bool>("SaveRootFile", false);
17  RootFileName = pset.getUntrackedParameter<std::string>("RootFileName", "RPCRecHitProbabilityDQM.root");
18 
19  muonLabel_ =consumes<reco::CandidateView>(pset.getParameter<edm::InputTag>("MuonLabel"));
20  muPtCut_ = pset.getUntrackedParameter<double>("MuonPtCut", 3.0);
21  muEtaCut_ = pset.getUntrackedParameter<double>("MuonEtaCut", 1.9);
22  scalersRawToDigiLabel_ = consumes<DcsStatusCollection>(pset.getParameter<edm::InputTag>("ScalersRawToDigiLabel"));
23 
24  subsystemFolder_ = pset.getUntrackedParameter<std::string>("RPCFolder", "RPC");
25  globalFolder_ = pset.getUntrackedParameter<std::string>("GlobalFolder", "SummaryHistograms");
26  muonFolder_ = pset.getUntrackedParameter<std::string>("MuonFolder", "Muon");
27 }
28 
30 
32 
33 
34  edm::LogInfo ("rpcrechitprobability") <<"[RPCRecHitProbability]: Begin Run " ;
35 
36  std::string currentFolder = subsystemFolder_ +"/"+muonFolder_+"/"+ globalFolder_;
37  ibooker.setCurrentFolder(currentFolder);
38 
39  int ptBins = 100 - (int)muPtCut_;
40 
41  //General part
42  NumberOfMuonEta_ = ibooker.book1D("NumberOfMuonEta", "Muons vs Eta", 20*muEtaCut_, -muEtaCut_, muEtaCut_ );
43  NumberOfMuonPt_B_ = ibooker.book1D("NumberOfMuonPt_Barrel", "Muons vs Pt - Barrel", ptBins, muPtCut_, 100);
44  NumberOfMuonPt_EP_ = ibooker.book1D("NumberOfMuonPt_EndcapP", "Muons vs Pt - Endcap+", ptBins , muPtCut_ , 100);
45  NumberOfMuonPt_EM_ = ibooker.book1D("NumberOfMuonPt_EndcapM", "Muons vs Pt - Endcap-", ptBins , muPtCut_ , 100);
46  NumberOfMuonPhi_B_ = ibooker.book1D("NumberOfMuonPhi_Barrel", "Muons vs Phi - Barrel", 144, -TMath::Pi(), TMath::Pi());
47  NumberOfMuonPhi_EP_ = ibooker.book1D("NumberOfMuonPhi_EndcapP", "Muons vs Phi - Endcap+", 144, -TMath::Pi(), TMath::Pi() );
48  NumberOfMuonPhi_EM_ = ibooker.book1D("NumberOfMuonPhi_EndcapM", "Muons vs Phi - Endcap-", 144, -TMath::Pi(), TMath::Pi());
49 
50  //RPC part
51  RPCRecHitMuonEta_ = ibooker.book2D("RPCRecHitMuonEta", "Number Of RecHits per Muons vs Eta", 20*muEtaCut_, -muEtaCut_, muEtaCut_, 7, 0.5, 7.5);
52 
53  std::stringstream name, title;
54  for(int i = 0 ; i< 6 ; i++) {
55  name.str("");
56  title.str("");
57  name<<(i+1)<<"RecHitMuonEta";
58  title<<"At least " <<(i+1)<<" Cluster vs Eta";
59  recHitEta_[i] = ibooker.book1D(name.str(), title.str(), 20*muEtaCut_, -muEtaCut_, muEtaCut_);
60 
61  name.str("");
62  title.str("");
63  name<<(i+1)<<"RecHitMuonPhiB";
64  title<<"At least " <<(i+1)<<" Cluster vs Phi-Barrel";
65  recHitPhi_B_[i] = ibooker.book1D(name.str(), title.str(), 144, -TMath::Pi(), TMath::Pi());
66 
67  name.str("");
68  title.str("");
69  name<<(i+1)<<"RecHitMuonPtB";
70  title<<"At least " <<(i+1)<<" Cluster vs Pt-Barrel";
71  recHitPt_B_[i] = ibooker.book1D(name.str(), title.str(), ptBins , muPtCut_ , 100);
72 
73  name.str("");
74  title.str("");
75  name<<(i+1)<<"RecHitMuonPhiEP";
76  title<<"At least " <<(i+1)<<" Cluster vs Phi-Endcap+";
77  recHitPhi_EP_[i] = ibooker.book1D(name.str(), title.str(), 144, -TMath::Pi(), TMath::Pi() );
78 
79  name.str("");
80  title.str("");
81  name<<(i+1)<<"RecHitMuonPtEP";
82  title<<"At least " <<(i+1)<<" Cluster vs Pt-Endcap+";
83  recHitPt_EP_[i] = ibooker.book1D(name.str(), title.str(), ptBins , muPtCut_ , 100);
84 
85  name.str("");
86  title.str("");
87  name<<(i+1)<<"RecHitMuonPhiEM";
88  title<<"At least " <<(i+1)<<" Cluster vs Phi-Endcap-";
89  recHitPhi_EM_[i] = ibooker.book1D(name.str(), title.str(), 144, -TMath::Pi(), TMath::Pi());
90 
91  name.str("");
92  title.str("");
93  name<<(i+1)<<"RecHitMuonPtEM";
94  title<<"At least " <<(i+1)<<" Cluster vs Pt-Endcap-";
95  recHitPt_EM_[i] = ibooker.book1D(name.str(), title.str(), ptBins , muPtCut_ , 100);
96 
97  }
98 
99  dcs_ = true;
100 }
101 
102 
104  dcs_ = true;
105  //Check HV status
106  this->makeDcsInfo(event);
107  if( !dcs_){
108  edm::LogWarning ("rpcrechitprobability") <<"[RPCRecHitProbability]: DCS bit OFF" ;
109  return;//if RPC not ON there's no need to continue
110  }
111 
112  counter++;
113  edm::LogInfo ("rpcrechitprobability") <<"[RPCRecHitProbability]: Beginning analyzing event " << counter;
114 
115  //Muons
117  event.getByToken(muonLabel_, muonCands);
118  std::map<RPCDetId , std::vector<RPCRecHit> > rechitMuon;
119 
120  if(muonCands.isValid()){
121 
122  int nStaMuons = muonCands->size();
123 
124  for( int i = 0; i < nStaMuons; i++ ) {
125 
126  const reco::Candidate & goodMuon = (*muonCands)[i];
127  const reco::Muon * muCand = dynamic_cast<const reco::Muon*>(&goodMuon);
128 
129  if(!muCand->isGlobalMuon())continue;
130  float eta = muCand->eta();
131  float pt = muCand->pt();
132  if( pt < muPtCut_ || fabs(eta)>muEtaCut_) continue;
133 
134  float phi = muCand->phi();
135 
136  NumberOfMuonEta_ -> Fill(eta);
137 
138  if(eta > 0.8){
139  NumberOfMuonPt_EP_ -> Fill(pt);
140  NumberOfMuonPhi_EP_ -> Fill(phi);
141  }else if (eta < -0.8){
142  NumberOfMuonPt_EM_ -> Fill(pt);
143  NumberOfMuonPhi_EM_ -> Fill(phi);
144  }else{
145  NumberOfMuonPt_B_ -> Fill(pt);
146  NumberOfMuonPhi_B_ -> Fill(phi);
147  }
148 
149  reco::Track muTrack = (*(muCand->outerTrack()));
150  std::vector<TrackingRecHitRef > rpcTrackRecHits;
151 
152  //loop on mu rechits
153 
154  int recHitCounter = 0;
155  for ( trackingRecHit_iterator it= muTrack.recHitsBegin(); it != muTrack.recHitsEnd() ; it++) {
156  if (!(*it)->isValid ()) continue;
157  int muSubDetId = (*it)->geographicalId().subdetId();
158  if(muSubDetId == MuonSubdetId::RPC) {
159  recHitCounter ++;
160  }
161  }// end loop on mu rechits
162 
163  RPCRecHitMuonEta_ -> Fill(eta, recHitCounter);
164 
165  int j = 0;
166  while (recHitCounter >= j+1 && j<6){
167 
168  if(recHitEta_[j]) recHitEta_[j]->Fill(eta);
169  if(eta > 0.8) {
170  recHitPt_EP_[j] -> Fill(pt);
171  recHitPhi_EP_[j] -> Fill(phi);
172  }else if (eta < -0.8){
173  recHitPt_EM_[j]-> Fill(pt);
174  recHitPhi_EM_[j]-> Fill(phi);
175  }else{
176  recHitPt_B_[j]-> Fill(pt);
177  recHitPhi_B_[j]-> Fill(phi);
178  }
179 
180  j++;
181  }
182 
183 
184  }
185  }else{
186  edm::LogError ("rpcrechitprobability") <<"[RPCRecHitProbability]: Muons - Product not valid for event" << counter;
187  }
188 
189 }
190 
192 
194 
195 
196  if ( ! e.getByToken(scalersRawToDigiLabel_, dcsStatus) ){
197  dcs_ = true;
198  return;
199  }
200 
201  if ( ! dcsStatus.isValid() )
202  {
203  edm::LogWarning("RPCDcsInfo") << "scalersRawToDigi not found" ;
204  dcs_ = true; // info not available: set to true
205  return;
206  }
207 
208  for (DcsStatusCollection::const_iterator dcsStatusItr = dcsStatus->begin();
209  dcsStatusItr != dcsStatus->end(); ++dcsStatusItr){
210 
211  if (!dcsStatusItr->ready(DcsStatus::RPC)) dcs_=false;
212  }
213 
214  return ;
215 }
216 
217 
MonitorElement * RPCRecHitMuonEta_
const double Pi
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * NumberOfMuonPhi_EM_
double eta() const final
momentum pseudorapidity
MonitorElement * NumberOfMuonPt_EP_
MonitorElement * NumberOfMuonEta_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
MonitorElement * recHitEta_[6]
MonitorElement * NumberOfMuonPt_B_
MonitorElement * NumberOfMuonPt_EM_
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
size_type size() const
double pt() const final
transverse momentum
MonitorElement * recHitPt_B_[6]
edm::EDGetTokenT< DcsStatusCollection > scalersRawToDigiLabel_
edm::EDGetTokenT< reco::CandidateView > muonLabel_
MonitorElement * recHitPhi_B_[6]
void analyze(const edm::Event &, const edm::EventSetup &) override
MonitorElement * recHitPhi_EP_[6]
void Fill(long long x)
MonitorElement * recHitPt_EM_[6]
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * NumberOfMuonPhi_EP_
bool isGlobalMuon() const override
Definition: Muon.h:268
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
void makeDcsInfo(const edm::Event &)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
MonitorElement * NumberOfMuonPhi_B_
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
RPCRecHitProbability(const edm::ParameterSet &)
bool isValid() const
Definition: HandleBase.h:74
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:51
MonitorElement * recHitPt_EP_[6]
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
MonitorElement * recHitPhi_EM_[6]
return(e1-e2)*(e1-e2)+dp *dp
static const int RPC
Definition: MuonSubdetId.h:14
double phi() const final
momentum azimuthal angle
Definition: event.py:1
Definition: Run.h:43
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:109