CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
31 
33 
34  edm::LogInfo ("rpcrechitprobability") <<"[RPCRecHitProbability]: Begin Run " ;
35 
38 
39  std::string currentFolder = subsystemFolder_ +"/"+muonFolder_+"/"+ globalFolder_;
40  dbe->setCurrentFolder(currentFolder);
41 
42  int ptBins = 100 - (int)muPtCut_;
43 
44  //General part
45  NumberOfMuonEta_ = dbe->get(currentFolder+"/NumberOfMuonEta");
47  NumberOfMuonEta_ = dbe->book1D("NumberOfMuonEta", "Muons vs Eta", 20*muEtaCut_, -muEtaCut_, muEtaCut_ );
48 
49  NumberOfMuonPt_B_ = dbe->get(currentFolder+"/NumberOfMuonPt_Barrel");
51  NumberOfMuonPt_B_ = dbe->book1D("NumberOfMuonPt_Barrel", "Muons vs Pt - Barrel", ptBins, muPtCut_, 100);
52 
53  NumberOfMuonPt_EP_ = dbe->get(currentFolder+"/NumberOfMuonPt_EndcapP");
55  NumberOfMuonPt_EP_ = dbe->book1D("NumberOfMuonPt_EndcapP", "Muons vs Pt - Endcap+", ptBins , muPtCut_ , 100);
56 
57  NumberOfMuonPt_EM_ = dbe->get(currentFolder+"/NumberOfMuonPt_EndcapM");
59  NumberOfMuonPt_EM_ = dbe->book1D("NumberOfMuonPt_EndcapM", "Muons vs Pt - Endcap-", ptBins , muPtCut_ , 100);
60 
61  NumberOfMuonPhi_B_ = dbe->get(currentFolder+"/NumberOfMuonPhi_Barrel");
63  NumberOfMuonPhi_B_ = dbe->book1D("NumberOfMuonPhi_Barrel", "Muons vs Phi - Barrel", 144, -TMath::Pi(), TMath::Pi());
64 
65  NumberOfMuonPhi_EP_ = dbe->get(currentFolder+"/NumberOfMuonPhi_EndcapP");
67  NumberOfMuonPhi_EP_ = dbe->book1D("NumberOfMuonPhi_EndcapP", "Muons vs Phi - Endcap+", 144, -TMath::Pi(), TMath::Pi() );
68 
69  NumberOfMuonPhi_EM_ = dbe->get(currentFolder+"/NumberOfMuonPhi_EndcapM");
71  NumberOfMuonPhi_EM_ = dbe->book1D("NumberOfMuonPhi_EndcapM", "Muons vs Phi - Endcap-", 144, -TMath::Pi(), TMath::Pi());
72 
73  //RPC part
74  RPCRecHitMuonEta_ = dbe->get(currentFolder+"/RPCRecHitMuonEta");
76  RPCRecHitMuonEta_ = dbe->book2D("RPCRecHitMuonEta", "Number Of RecHits per Muons vs Eta", 20*muEtaCut_, -muEtaCut_, muEtaCut_, 7, 0.5, 7.5);
77 
78  std::stringstream name, title;
79  for(int i = 0 ; i< 6 ; i++) {
80  name.str("");
81  title.str("");
82  name<<(i+1)<<"RecHitMuonEta";
83  title<<"At least " <<(i+1)<<" Cluster vs Eta";
84  recHitEta_[i] = dbe->book1D(name.str(), title.str(), 20*muEtaCut_, -muEtaCut_, muEtaCut_);
85 
86  name.str("");
87  title.str("");
88  name<<(i+1)<<"RecHitMuonPhiB";
89  title<<"At least " <<(i+1)<<" Cluster vs Phi-Barrel";
90  recHitPhi_B_[i] = dbe->book1D(name.str(), title.str(), 144, -TMath::Pi(), TMath::Pi());
91 
92  name.str("");
93  title.str("");
94  name<<(i+1)<<"RecHitMuonPtB";
95  title<<"At least " <<(i+1)<<" Cluster vs Pt-Barrel";
96  recHitPt_B_[i] = dbe->book1D(name.str(), title.str(), ptBins , muPtCut_ , 100);
97 
98  name.str("");
99  title.str("");
100  name<<(i+1)<<"RecHitMuonPhiEP";
101  title<<"At least " <<(i+1)<<" Cluster vs Phi-Endcap+";
102  recHitPhi_EP_[i] = dbe->book1D(name.str(), title.str(), 144, -TMath::Pi(), TMath::Pi() );
103 
104  name.str("");
105  title.str("");
106  name<<(i+1)<<"RecHitMuonPtEP";
107  title<<"At least " <<(i+1)<<" Cluster vs Pt-Endcap+";
108  recHitPt_EP_[i] = dbe->book1D(name.str(), title.str(), ptBins , muPtCut_ , 100);
109 
110  name.str("");
111  title.str("");
112  name<<(i+1)<<"RecHitMuonPhiEM";
113  title<<"At least " <<(i+1)<<" Cluster vs Phi-Endcap-";
114  recHitPhi_EM_[i] = dbe->book1D(name.str(), title.str(), 144, -TMath::Pi(), TMath::Pi());
115 
116  name.str("");
117  title.str("");
118  name<<(i+1)<<"RecHitMuonPtEM";
119  title<<"At least " <<(i+1)<<" Cluster vs Pt-Endcap-";
120  recHitPt_EM_[i] = dbe->book1D(name.str(), title.str(), ptBins , muPtCut_ , 100);
121 
122  }
123 
124  dcs_ = true;
125 }
126 
129  dbe = 0;
130 }
131 
133 
134 
136  dcs_ = true;
137  //Check HV status
138  this->makeDcsInfo(event);
139  if( !dcs_){
140  edm::LogWarning ("rpcrechitprobability") <<"[RPCRecHitProbability]: DCS bit OFF" ;
141  return;//if RPC not ON there's no need to continue
142  }
143 
144  counter++;
145  edm::LogInfo ("rpcrechitprobability") <<"[RPCRecHitProbability]: Beginning analyzing event " << counter;
146 
147  //Muons
149  event.getByToken(muonLabel_, muonCands);
150  std::map<RPCDetId , std::vector<RPCRecHit> > rechitMuon;
151 
152  if(muonCands.isValid()){
153 
154  int nStaMuons = muonCands->size();
155 
156  for( int i = 0; i < nStaMuons; i++ ) {
157 
158  const reco::Candidate & goodMuon = (*muonCands)[i];
159  const reco::Muon * muCand = dynamic_cast<const reco::Muon*>(&goodMuon);
160 
161  if(!muCand->isGlobalMuon())continue;
162  float eta = muCand->eta();
163  float pt = muCand->pt();
164  if( pt < muPtCut_ || fabs(eta)>muEtaCut_) continue;
165 
166  float phi = muCand->phi();
167 
168  NumberOfMuonEta_ -> Fill(eta);
169 
170  if(eta > 0.8){
171  NumberOfMuonPt_EP_ -> Fill(pt);
172  NumberOfMuonPhi_EP_ -> Fill(phi);
173  }else if (eta < -0.8){
174  NumberOfMuonPt_EM_ -> Fill(pt);
175  NumberOfMuonPhi_EM_ -> Fill(phi);
176  }else{
177  NumberOfMuonPt_B_ -> Fill(pt);
178  NumberOfMuonPhi_B_ -> Fill(phi);
179  }
180 
181  reco::Track muTrack = (*(muCand->outerTrack()));
182  std::vector<TrackingRecHitRef > rpcTrackRecHits;
183 
184  //loop on mu rechits
185 
186  int recHitCounter = 0;
187  for ( trackingRecHit_iterator it= muTrack.recHitsBegin(); it != muTrack.recHitsEnd() ; it++) {
188  if (!(*it)->isValid ()) continue;
189  int muSubDetId = (*it)->geographicalId().subdetId();
190  if(muSubDetId == MuonSubdetId::RPC) {
191  recHitCounter ++;
192  }
193  }// end loop on mu rechits
194 
195  RPCRecHitMuonEta_ -> Fill(eta, recHitCounter);
196 
197  int j = 0;
198  while (recHitCounter >= j+1 && j<6){
199 
200  if(recHitEta_[j]) recHitEta_[j]->Fill(eta);
201  if(eta > 0.8) {
202  recHitPt_EP_[j] -> Fill(pt);
203  recHitPhi_EP_[j] -> Fill(phi);
204  }else if (eta < -0.8){
205  recHitPt_EM_[j]-> Fill(pt);
206  recHitPhi_EM_[j]-> Fill(phi);
207  }else{
208  recHitPt_B_[j]-> Fill(pt);
209  recHitPhi_B_[j]-> Fill(phi);
210  }
211 
212  j++;
213  }
214 
215 
216  }
217  }else{
218  edm::LogError ("rpcrechitprobability") <<"[RPCRecHitProbability]: Muons - Product not valid for event" << counter;
219  }
220 
221 }
222 
224 
226 
227 
228  if ( ! e.getByToken(scalersRawToDigiLabel_, dcsStatus) ){
229  dcs_ = true;
230  return;
231  }
232 
233  if ( ! dcsStatus.isValid() )
234  {
235  edm::LogWarning("RPCDcsInfo") << "scalersRawToDigi not found" ;
236  dcs_ = true; // info not available: set to true
237  return;
238  }
239 
240  for (DcsStatusCollection::const_iterator dcsStatusItr = dcsStatus->begin();
241  dcsStatusItr != dcsStatus->end(); ++dcsStatusItr){
242 
243  if (!dcsStatusItr->ready(DcsStatus::RPC)) dcs_=false;
244  }
245 
246  return ;
247 }
248 
249 
MonitorElement * RPCRecHitMuonEta_
const double Pi
void beginRun(const edm::Run &r, const edm::EventSetup &c)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
MonitorElement * NumberOfMuonPhi_EM_
MonitorElement * NumberOfMuonPt_EP_
MonitorElement * NumberOfMuonEta_
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:873
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
MonitorElement * recHitEta_[6]
MonitorElement * NumberOfMuonPt_B_
MonitorElement * NumberOfMuonPt_EM_
bool isGlobalMuon() const
Definition: Muon.h:218
MonitorElement * recHitPt_B_[6]
edm::EDGetTokenT< DcsStatusCollection > scalersRawToDigiLabel_
T eta() const
edm::EDGetTokenT< reco::CandidateView > muonLabel_
virtual void endJob(void)
MonitorElement * recHitPhi_B_[6]
MonitorElement * recHitPhi_EP_[6]
void Fill(long long x)
MonitorElement * recHitPt_EM_[6]
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
MonitorElement * NumberOfMuonPhi_EP_
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
void makeDcsInfo(const edm::Event &)
void removeElement(const std::string &name)
Definition: DQMStore.cc:2773
int j
Definition: DBlmapReader.cc:9
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2297
MonitorElement * NumberOfMuonPhi_B_
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:62
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1624
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
RPCRecHitProbability(const edm::ParameterSet &)
bool isValid() const
Definition: HandleBase.h:76
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:51
virtual void analyze(const edm::Event &, const edm::EventSetup &)
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
MonitorElement * recHitPt_EP_[6]
DQMStore * dbe
DQM store.
MonitorElement * recHitPhi_EM_[6]
return(e1-e2)*(e1-e2)+dp *dp
static const int RPC
Definition: MuonSubdetId.h:14
static std::atomic< unsigned int > counter
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1001
virtual float pt() const GCC11_FINAL
transverse momentum
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:585
Definition: Run.h:41
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:64
Definition: DDAxes.h:10