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>
7 //Geometry
10 //Tracking Tools
12 //FW Core
14 //Reco Muon
16 
18 
19  saveRootFile = pset.getUntrackedParameter<bool>("SaveRootFile", false);
20  RootFileName = pset.getUntrackedParameter<std::string>("RootFileName", "RPCRecHitProbabilityDQM.root");
21 
22  muonLabel_ = pset.getParameter<edm::InputTag>("MuonLabel");
23  muPtCut_ = pset.getUntrackedParameter<double>("MuonPtCut", 3.0);
24  muEtaCut_ = pset.getUntrackedParameter<double>("MuonEtaCut", 1.9);
25 
26  subsystemFolder_ = pset.getUntrackedParameter<std::string>("RPCFolder", "RPC");
27  globalFolder_ = pset.getUntrackedParameter<std::string>("GlobalFolder", "SummaryHistograms");
28  muonFolder_ = pset.getUntrackedParameter<std::string>("MuonFolder", "Muon");
29 }
30 
33 
35 
36  edm::LogInfo ("rpcrechitprobability") <<"[RPCRecHitProbability]: Begin Run " ;
37 
40 
41  std::string currentFolder = subsystemFolder_ +"/"+muonFolder_+"/"+ globalFolder_;
42  dbe->setCurrentFolder(currentFolder);
43 
44  int ptBins = 100 - (int)muPtCut_;
45 
46  //General part
47  NumberOfMuonEta_ = dbe->get(currentFolder+"/NumberOfMuonEta");
49  NumberOfMuonEta_ = dbe->book1D("NumberOfMuonEta", "Muons vs Eta", 20*muEtaCut_, -muEtaCut_, muEtaCut_ );
50 
51  NumberOfMuonPt_B_ = dbe->get(currentFolder+"/NumberOfMuonPt_Barrel");
53  NumberOfMuonPt_B_ = dbe->book1D("NumberOfMuonPt_Barrel", "Muons vs Pt - Barrel", ptBins, muPtCut_, 100);
54 
55  NumberOfMuonPt_EP_ = dbe->get(currentFolder+"/NumberOfMuonPt_EndcapP");
57  NumberOfMuonPt_EP_ = dbe->book1D("NumberOfMuonPt_EndcapP", "Muons vs Pt - Endcap+", ptBins , muPtCut_ , 100);
58 
59  NumberOfMuonPt_EM_ = dbe->get(currentFolder+"/NumberOfMuonPt_EndcapM");
61  NumberOfMuonPt_EM_ = dbe->book1D("NumberOfMuonPt_EndcapM", "Muons vs Pt - Endcap-", ptBins , muPtCut_ , 100);
62 
63  NumberOfMuonPhi_B_ = dbe->get(currentFolder+"/NumberOfMuonPhi_Barrel");
65  NumberOfMuonPhi_B_ = dbe->book1D("NumberOfMuonPhi_Barrel", "Muons vs Phi - Barrel", 144, -TMath::Pi(), TMath::Pi());
66 
67  NumberOfMuonPhi_EP_ = dbe->get(currentFolder+"/NumberOfMuonPhi_EndcapP");
69  NumberOfMuonPhi_EP_ = dbe->book1D("NumberOfMuonPhi_EndcapP", "Muons vs Phi - Endcap+", 144, -TMath::Pi(), TMath::Pi() );
70 
71  NumberOfMuonPhi_EM_ = dbe->get(currentFolder+"/NumberOfMuonPhi_EndcapM");
73  NumberOfMuonPhi_EM_ = dbe->book1D("NumberOfMuonPhi_EndcapM", "Muons vs Phi - Endcap-", 144, -TMath::Pi(), TMath::Pi());
74 
75  //RPC part
76  RPCRecHitMuonEta_ = dbe->get(currentFolder+"/RPCRecHitMuonEta");
78  RPCRecHitMuonEta_ = dbe->book2D("RPCRecHitMuonEta", "Number Of RecHits per Muons vs Eta", 20*muEtaCut_, -muEtaCut_, muEtaCut_, 7, 0.5, 7.5);
79 
80  std::stringstream name, title;
81  for(int i = 0 ; i< 6 ; i++) {
82  name.str("");
83  title.str("");
84  name<<(i+1)<<"RecHitMuonEta";
85  title<<"At least " <<(i+1)<<" Cluster vs Eta";
86  recHitEta_[i] = dbe->book1D(name.str(), title.str(), 20*muEtaCut_, -muEtaCut_, muEtaCut_);
87 
88  name.str("");
89  title.str("");
90  name<<(i+1)<<"RecHitMuonPhiB";
91  title<<"At least " <<(i+1)<<" Cluster vs Phi-Barrel";
92  recHitPhi_B_[i] = dbe->book1D(name.str(), title.str(), 144, -TMath::Pi(), TMath::Pi());
93 
94  name.str("");
95  title.str("");
96  name<<(i+1)<<"RecHitMuonPtB";
97  title<<"At least " <<(i+1)<<" Cluster vs Pt-Barrel";
98  recHitPt_B_[i] = dbe->book1D(name.str(), title.str(), ptBins , muPtCut_ , 100);
99 
100  name.str("");
101  title.str("");
102  name<<(i+1)<<"RecHitMuonPhiEP";
103  title<<"At least " <<(i+1)<<" Cluster vs Phi-Endcap+";
104  recHitPhi_EP_[i] = dbe->book1D(name.str(), title.str(), 144, -TMath::Pi(), TMath::Pi() );
105 
106  name.str("");
107  title.str("");
108  name<<(i+1)<<"RecHitMuonPtEP";
109  title<<"At least " <<(i+1)<<" Cluster vs Pt-Endcap+";
110  recHitPt_EP_[i] = dbe->book1D(name.str(), title.str(), ptBins , muPtCut_ , 100);
111 
112  name.str("");
113  title.str("");
114  name<<(i+1)<<"RecHitMuonPhiEM";
115  title<<"At least " <<(i+1)<<" Cluster vs Phi-Endcap-";
116  recHitPhi_EM_[i] = dbe->book1D(name.str(), title.str(), 144, -TMath::Pi(), TMath::Pi());
117 
118  name.str("");
119  title.str("");
120  name<<(i+1)<<"RecHitMuonPtEM";
121  title<<"At least " <<(i+1)<<" Cluster vs Pt-Endcap-";
122  recHitPt_EM_[i] = dbe->book1D(name.str(), title.str(), ptBins , muPtCut_ , 100);
123 
124  }
125 
126  dcs_ = true;
127 }
128 
131  dbe = 0;
132 }
133 
135 
136 
138  dcs_ = true;
139  //Check HV status
140  this->makeDcsInfo(event);
141  if( !dcs_){
142  edm::LogWarning ("rpcrechitprobability") <<"[RPCRecHitProbability]: DCS bit OFF" ;
143  return;//if RPC not ON there's no need to continue
144  }
145 
146  counter++;
147  edm::LogInfo ("rpcrechitprobability") <<"[RPCRecHitProbability]: Beginning analyzing event " << counter;
148 
149  //Muons
151  event.getByLabel(muonLabel_, muonCands);
152  std::map<RPCDetId , std::vector<RPCRecHit> > rechitMuon;
153 
154  if(muonCands.isValid()){
155 
156  int nStaMuons = muonCands->size();
157 
158  for( int i = 0; i < nStaMuons; i++ ) {
159 
160  const reco::Candidate & goodMuon = (*muonCands)[i];
161  const reco::Muon * muCand = dynamic_cast<const reco::Muon*>(&goodMuon);
162 
163  if(!muCand->isGlobalMuon())continue;
164  float eta = muCand->eta();
165  float pt = muCand->pt();
166  if( pt < muPtCut_ || fabs(eta)>muEtaCut_) continue;
167 
168  float phi = muCand->phi();
169 
170  NumberOfMuonEta_ -> Fill(eta);
171 
172  if(eta > 0.8){
173  NumberOfMuonPt_EP_ -> Fill(pt);
174  NumberOfMuonPhi_EP_ -> Fill(phi);
175  }else if (eta < -0.8){
176  NumberOfMuonPt_EM_ -> Fill(pt);
177  NumberOfMuonPhi_EM_ -> Fill(phi);
178  }else{
179  NumberOfMuonPt_B_ -> Fill(pt);
180  NumberOfMuonPhi_B_ -> Fill(phi);
181  }
182 
183  reco::Track muTrack = (*(muCand->outerTrack()));
184  std::vector<TrackingRecHitRef > rpcTrackRecHits;
185 
186  //loop on mu rechits
187 
188  int recHitCounter = 0;
189  for ( trackingRecHit_iterator it= muTrack.recHitsBegin(); it != muTrack.recHitsEnd() ; it++) {
190  if (!(*it)->isValid ()) continue;
191  int muSubDetId = (*it)->geographicalId().subdetId();
192  if(muSubDetId == MuonSubdetId::RPC) {
193  recHitCounter ++;
194  }
195  }// end loop on mu rechits
196 
197  RPCRecHitMuonEta_ -> Fill(eta, recHitCounter);
198 
199  int j = 0;
200  while (recHitCounter >= j+1 && j<6){
201 
202  if(recHitEta_[j]) recHitEta_[j]->Fill(eta);
203  if(eta > 0.8) {
204  recHitPt_EP_[j] -> Fill(pt);
205  recHitPhi_EP_[j] -> Fill(phi);
206  }else if (eta < -0.8){
207  recHitPt_EM_[j]-> Fill(pt);
208  recHitPhi_EM_[j]-> Fill(phi);
209  }else{
210  recHitPt_B_[j]-> Fill(pt);
211  recHitPhi_B_[j]-> Fill(phi);
212  }
213 
214  j++;
215  }
216 
217 
218  }
219  }else{
220  edm::LogError ("rpcrechitprobability") <<"[RPCRecHitProbability]: Muons - Product not valid for event" << counter;
221  }
222 
223 }
224 
226 
228 
229  if ( ! e.getByLabel("scalersRawToDigi", dcsStatus) ){
230  dcs_ = true;
231  return;
232  }
233 
234  if ( ! dcsStatus.isValid() )
235  {
236  edm::LogWarning("RPCDcsInfo") << "scalersRawToDigi not found" ;
237  dcs_ = true; // info not available: set to true
238  return;
239  }
240 
241  for (DcsStatusCollection::const_iterator dcsStatusItr = dcsStatus->begin();
242  dcsStatusItr != dcsStatus->end(); ++dcsStatusItr){
243 
244  if (!dcsStatusItr->ready(DcsStatus::RPC)) dcs_=false;
245  }
246 
247  return ;
248 }
249 
250 
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:722
MonitorElement * recHitEta_[6]
MonitorElement * NumberOfMuonPt_B_
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2118
MonitorElement * NumberOfMuonPt_EM_
bool isGlobalMuon() const
Definition: Muon.h:219
MonitorElement * recHitPt_B_[6]
T eta() const
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:2577
int j
Definition: DBlmapReader.cc:9
MonitorElement * NumberOfMuonPhi_B_
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:63
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1473
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 &)
Data Format.
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:52
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]
static const int RPC
Definition: MuonSubdetId.h:16
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:850
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:434
Definition: Run.h:36
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:65
Definition: DDAxes.h:10