CMS 3D CMS Logo

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