CMS 3D CMS Logo

MuonTiming.cc
Go to the documentation of this file.
2 
7 
10 
12 
13 #include <string>
14 #include "TMath.h"
15 using namespace std;
16 using namespace edm;
17 
19  const edm::ParameterSet& parameters = pSet;
20 
21  // Input booleans
22 
23  // the services:
24  theMuonCollectionLabel_ = consumes<edm::View<reco::Muon> >(parameters.getParameter<edm::InputTag>("MuonCollection"));
25 
26  tnbins_ = parameters.getParameter<int>("tnbins");
27  tnbinsrpc_ = parameters.getParameter<int>("tnbinsrpc");
28  terrnbins_ = parameters.getParameter<int>("terrnbins");
29  terrnbinsrpc_ = parameters.getParameter<int>("terrnbinsrpc");
30  ndofnbins_ = parameters.getParameter<int>("ndofnbins");
31  ptnbins_ = parameters.getParameter<int>("ptnbins");
32  etanbins_ = parameters.getParameter<int>("etanbins");
33  tmax_ = parameters.getParameter<double>("tmax");
34  tmaxrpc_ = parameters.getParameter<double>("tmaxrpc");
35  terrmax_ = parameters.getParameter<double>("terrmax");
36  terrmaxrpc_ = parameters.getParameter<double>("terrmaxrpc");
37  ndofmax_ = parameters.getParameter<double>("ndofmax");
38  ptmax_ = parameters.getParameter<double>("ptmax");
39  etamax_ = parameters.getParameter<double>("etamax");
40  tmin_ = parameters.getParameter<double>("tmin");
41  tminrpc_ = parameters.getParameter<double>("tminrpc");
42  terrmin_ = parameters.getParameter<double>("terrmin");
43  terrminrpc_ = parameters.getParameter<double>("terrminrpc");
44  ndofmin_ = parameters.getParameter<double>("ndofmin");
45  ptmin_ = parameters.getParameter<double>("ptmin");
46  etamin_ = parameters.getParameter<double>("etamin");
47 
48  etaBarrelMin_ = parameters.getParameter<double>("etaBarrelMin");
49  etaBarrelMax_ = parameters.getParameter<double>("etaBarrelMax");
50  etaEndcapMin_ = parameters.getParameter<double>("etaEndcapMin");
51  etaEndcapMax_ = parameters.getParameter<double>("etaEndcapMax");
52  etaOverlapMin_ = parameters.getParameter<double>("etaOverlapMin");
53  etaOverlapMax_ = parameters.getParameter<double>("etaOverlapMax");
54 
55  theFolder_ = parameters.getParameter<string>("folder");
56 }
57 
59 
61  edm::Run const& /*iRun*/,
62  edm::EventSetup const& /* iSetup */) {
63  ibooker.cd();
64  ibooker.setCurrentFolder(theFolder_);
65 
66  EtaName_.push_back("_Overlap");
67  EtaName_.push_back("_Barrel");
68  EtaName_.push_back("_Endcap");
69  ObjectName_.push_back("Sta_");
70  ObjectName_.push_back("Glb_");
71 
72  for (unsigned int iEtaRegion = 0; iEtaRegion < 3; iEtaRegion++) {
73  /*std::array<MonitorElement*, 1> timeNDofv_;
74  std::array<MonitorElement*, 1> timeAtIpInOutv_;
75  std::array<MonitorElement*, 1> timeAtIpInOutRPCv_;
76  std::array<MonitorElement*, 1> timeAtIpInOutErrv_;
77  std::array<MonitorElement*, 1> timeAtIpInOutErrRPCv_;*/
78  //Only creating so far the timing information for STA muons, however the code can be extended to also Glb by just setting the limit of this loop to 2
79  for (unsigned int iObjectName = 0; iObjectName < 1; iObjectName++) {
80  timeNDof_[iEtaRegion][iObjectName] = ibooker.book1D(
81  ObjectName_[iObjectName] + "timenDOF" + EtaName_[iEtaRegion], "muon time ndof", ndofnbins_, 0, ndofmax_);
82  timeAtIpInOut_[iEtaRegion][iObjectName] = ibooker.book1D(
83  ObjectName_[iObjectName] + "timeAtIpInOut" + EtaName_[iEtaRegion], "muon time", tnbins_, tmin_, tmax_);
84  timeAtIpInOutRPC_[iEtaRegion][iObjectName] =
85  ibooker.book1D(ObjectName_[iObjectName] + "timeAtIpInOutRPC" + EtaName_[iEtaRegion],
86  "muon rpc time",
87  tnbinsrpc_,
88  tminrpc_,
89  tmaxrpc_);
90  timeAtIpInOutErr_[iEtaRegion][iObjectName] =
91  ibooker.book1D(ObjectName_[iObjectName] + "timeAtIpInOutErr" + EtaName_[iEtaRegion],
92  "muon time error",
93  terrnbins_,
94  terrmin_,
95  terrmax_);
96  timeAtIpInOutErrRPC_[iEtaRegion][iObjectName] =
97  ibooker.book1D(ObjectName_[iObjectName] + "timeAtIpInOutRPCErr" + EtaName_[iEtaRegion],
98  "muon rpc time error",
99  terrnbinsrpc_,
100  terrminrpc_,
101  terrmaxrpc_);
102  timeNDof_[iEtaRegion][iObjectName]->setAxisTitle("Time nDof");
103  timeAtIpInOut_[iEtaRegion][iObjectName]->setAxisTitle("Combined time [ns]");
104  timeAtIpInOutErr_[iEtaRegion][iObjectName]->setAxisTitle("Combined time Error [ns]");
105  timeAtIpInOutRPC_[iEtaRegion][iObjectName]->setAxisTitle("RPC time [ns]");
106  timeAtIpInOutErrRPC_[iEtaRegion][iObjectName]->setAxisTitle("RPC time Error [ns]");
107  }
108  /*
109  timeNDof_[iEtaregion] = timeNDofv_);
110  timeAtIpInOut_.push_back(timeAtIpInOutv_);
111  timeAtIpInOutRPC_.push_back(timeAtIpInOutRPCv_);
112  timeAtIpInOutErr_.push_back(timeAtIpInOutErrv_);
113  timeAtIpInOutErrRPC_.push_back(timeAtIpInOutErrRPCv_);
114  */
115  }
116 
117  //Only creating so far the timing information for STA muons, however the code can be extended to also Glb by just setting the limit of this loop to 2
118  for (unsigned int iObjectName = 0; iObjectName < 1; iObjectName++) {
119  etaptVeto_[iObjectName] = ibooker.book2D(ObjectName_[iObjectName] + "etapt",
120  "Eta and Pt distribution for muons not passing the veto",
121  ptnbins_,
122  ptmin_,
123  ptmax_,
124  etanbins_,
125  etamin_,
126  etamax_);
127  etaVeto_[iObjectName] = ibooker.book1D(ObjectName_[iObjectName] + "eta",
128  "Eta distribution for muons not passing the veto",
129  etanbins_,
130  etamin_,
131  etamax_);
132  ptVeto_[iObjectName] = ibooker.book1D(
133  ObjectName_[iObjectName] + "pt", "Pt distribution for muons not passing the veto", ptnbins_, ptmin_, ptmax_);
134  yields_[iObjectName] = ibooker.book1D(
135  ObjectName_[iObjectName] + "yields", "Number of muons passing/not passing the different conditions", 10, 0, 10);
136  yields_[iObjectName]->setBinLabel(1, "Not valid time");
137  yields_[iObjectName]->setBinLabel(2, "Valid time");
138  yields_[iObjectName]->setBinLabel(3, "Not Combined time");
139  yields_[iObjectName]->setBinLabel(4, "Combined time");
140  yields_[iObjectName]->setBinLabel(5, "Not RPC time");
141  yields_[iObjectName]->setBinLabel(6, "RPC time");
142  yields_[iObjectName]->setBinLabel(7, "Combined not RPC");
143  yields_[iObjectName]->setBinLabel(8, "RPC not Combined");
144  yields_[iObjectName]->setBinLabel(9, "Not passing veto");
145  yields_[iObjectName]->setBinLabel(10, "Passing veto");
146  etaptVeto_[iObjectName]->setAxisTitle("p_{T} [GeV]");
147  etaptVeto_[iObjectName]->setAxisTitle("#eta#", 2);
148  ptVeto_[iObjectName]->setAxisTitle("p_{T} [GeV]");
149  etaVeto_[iObjectName]->setAxisTitle("#eta");
150  }
151 }
152 
154  LogTrace(metname_) << "[MuonTiming] Analyze the mu";
155 
156  // Take the muon container
158  iEvent.getByToken(theMuonCollectionLabel_, muons);
159 
160  if (!muons.isValid())
161  return;
162 
163  for (edm::View<reco::Muon>::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
164  const reco::MuonTime time = muon->time();
165  const reco::MuonTime rpcTime = muon->rpcTime();
166  //Only creating so far the timing information for STA muons
167  if (!muon->isStandAloneMuon() || muon->isGlobalMuon())
168  continue;
170  //Select whether it's a global or standalone muon
171  object_ theObject = sta;
172  if (muon->isGlobalMuon()) {
173  track = muon->combinedMuon();
174  theObject = glb;
175  } else {
176  track = muon->standAloneMuon();
177  theObject = sta;
178  }
179 
180  //These definitions have been taken from Piotr Traczyk
181  bool cmbok = (time.nDof > 7);
182  bool rpcok = (rpcTime.nDof > 1 && rpcTime.timeAtIpInOutErr == 0);
183  bool veto = false;
184  if (rpcok) {
185  if ((fabs(rpcTime.timeAtIpInOut) > 10) && !(cmbok && fabs(time.timeAtIpInOut) < 10))
186  veto = true;
187  else if (cmbok && (time.timeAtIpInOut > 20 || time.timeAtIpInOut < -45))
188  veto = true;
189  }
190 
191  //std::cout << time.timeAtIpInOut << std::endl;
192  //Filling the yields histogram
193  if (muon->isTimeValid())
194  yields_[theObject]->Fill(1);
195  else
196  yields_[theObject]->Fill(0);
197 
198  if (cmbok)
199  yields_[theObject]->Fill(3);
200  else
201  yields_[theObject]->Fill(2);
202 
203  if (rpcok)
204  yields_[theObject]->Fill(5);
205  else
206  yields_[theObject]->Fill(4);
207 
208  if (cmbok && !rpcok)
209  yields_[theObject]->Fill(6);
210  if (!cmbok && rpcok)
211  yields_[theObject]->Fill(7);
212 
213  if (veto)
214  yields_[theObject]->Fill(8);
215  else
216  yields_[theObject]->Fill(9);
217 
218  //Starting now with the pt and eta for vetoed and not vetoed muons
219  if (veto) {
220  etaptVeto_[theObject]->Fill(track->pt(), track->eta());
221  etaVeto_[theObject]->Fill(track->eta());
222  ptVeto_[theObject]->Fill(track->pt());
223  }
224 
225  //Check the eta region of the muon
226  eta_ theEta = barrel;
227  if (fabs(track->eta()) >= etaBarrelMin_ && fabs(track->eta()) <= etaBarrelMax_)
228  theEta = barrel;
229  if (fabs(track->eta()) >= etaOverlapMin_ && fabs(track->eta()) <= etaOverlapMax_)
230  theEta = overlap;
231  if (fabs(track->eta()) >= etaEndcapMin_ && fabs(track->eta()) <= etaEndcapMax_)
232  theEta = endcap;
233  timeNDof_[theEta][theObject]->Fill(time.nDof);
234  timeAtIpInOut_[theEta][theObject]->Fill(time.timeAtIpInOut);
235  timeAtIpInOutRPC_[theEta][theObject]->Fill(rpcTime.timeAtIpInOut);
236  timeAtIpInOutErr_[theEta][theObject]->Fill(time.timeAtIpInOutErr);
237  timeAtIpInOutErrRPC_[theEta][theObject]->Fill(rpcTime.timeAtIpInOutErr);
238  }
239 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: MuonTiming.cc:60
double glb
Definition: hdecay.h:105
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
#define LogTrace(id)
int iEvent
Definition: GenABIO.cc:224
void analyze(const edm::Event &, const edm::EventSetup &) override
Inizialize parameters for histo binning.
Definition: MuonTiming.cc:153
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
~MuonTiming() override
Destructor.
Definition: MuonTiming.cc:58
float timeAtIpInOutErr
Definition: MuonTime.h:14
int nDof
number of muon stations used
Definition: MuonTime.h:9
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
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
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
MuonTiming(const edm::ParameterSet &)
Constructor.
Definition: MuonTiming.cc:18
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
float timeAtIpInOut
Definition: MuonTime.h:13
Definition: Run.h:45
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)