CMS 3D CMS Logo

MuonSeedsAnalyzer.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2008/03/25
5  18:37:05 $
6  * \author G. Mila - INFN Torino
7  */
8 
10 
19 
21 
24 
30 
31 #include <string>
32 
33 using namespace std;
34 using namespace edm;
35 
37  parameters = pSet;
38 
39  theService = new MuonServiceProxy(parameters.getParameter<ParameterSet>("ServiceParameters"), consumesCollector());
40 
41  theSeedsCollectionLabel_ = consumes<TrajectorySeedCollection>(parameters.getParameter<InputTag>("SeedCollection"));
42 
43  seedHitBin = parameters.getParameter<int>("RecHitBin");
44  seedHitMin = parameters.getParameter<double>("RecHitMin");
45  seedHitMax = parameters.getParameter<double>("RecHitMax");
46  PhiBin = parameters.getParameter<int>("PhiBin");
47  PhiMin = parameters.getParameter<double>("PhiMin");
48  PhiMax = parameters.getParameter<double>("PhiMax");
49  EtaBin = parameters.getParameter<int>("EtaBin");
50  EtaMin = parameters.getParameter<double>("EtaMin");
51  EtaMax = parameters.getParameter<double>("EtaMax");
52  ThetaBin = parameters.getParameter<int>("ThetaBin");
53  ThetaMin = parameters.getParameter<double>("ThetaMin");
54  ThetaMax = parameters.getParameter<double>("ThetaMax");
55  seedPtBin = parameters.getParameter<int>("seedPtBin");
56  seedPtMin = parameters.getParameter<double>("seedPtMin");
57  seedPtMax = parameters.getParameter<double>("seedPtMax");
58  seedPxyzBin = parameters.getParameter<int>("seedPxyzBin");
59  seedPxyzMin = parameters.getParameter<double>("seedPxyzMin");
60  seedPxyzMax = parameters.getParameter<double>("seedPxyzMax");
61  pErrBin = parameters.getParameter<int>("pErrBin");
62  pErrMin = parameters.getParameter<double>("pErrMin");
63  pErrMax = parameters.getParameter<double>("pErrMax");
64  pxyzErrBin = parameters.getParameter<int>("pxyzErrBin");
65  pxyzErrMin = parameters.getParameter<double>("pxyzErrMin");
66  pxyzErrMax = parameters.getParameter<double>("pxyzErrMax");
67  phiErrBin = parameters.getParameter<int>("phiErrBin");
68  phiErrMin = parameters.getParameter<double>("phiErrMin");
69  phiErrMax = parameters.getParameter<double>("phiErrMax");
70  etaErrBin = parameters.getParameter<int>("etaErrBin");
71  etaErrMin = parameters.getParameter<double>("etaErrMin");
72  etaErrMax = parameters.getParameter<double>("etaErrMax");
73 }
74 MuonSeedsAnalyzer::~MuonSeedsAnalyzer() { delete theService; }
76  ibooker.cd();
77  ibooker.setCurrentFolder("Muons/MuonSeedsAnalyzer");
78 
79  string histname = "NumberOfRecHitsPerSeed_";
80  NumberOfRecHitsPerSeed = ibooker.book1D(histname, "Number of seed recHits", seedHitBin, seedHitMin, seedHitMax);
81 
82  histname = "seedPhi_";
83  seedPhi = ibooker.book1D(histname, "Seed #phi", PhiBin, PhiMin, PhiMax);
84  seedPhi->setAxisTitle("rad");
85 
86  histname = "seedEta_";
87  seedEta = ibooker.book1D(histname, "Seed #eta", EtaBin, EtaMin, EtaMax);
88 
89  histname = "seedTheta_";
90  seedTheta = ibooker.book1D(histname, "Seed #theta", ThetaBin, ThetaMin, ThetaMax);
91  seedTheta->setAxisTitle("rad");
92 
93  histname = "seedPt_";
94  seedPt = ibooker.book1D(histname, "Seed p_{t}", seedPtBin, seedPtMin, seedPtMax);
95  seedPt->setAxisTitle("GeV");
96 
97  histname = "seedPx_";
98  seedPx = ibooker.book1D(histname, "Seed p_{x}", seedPxyzBin, seedPxyzMin, seedPxyzMax);
99  seedPx->setAxisTitle("GeV");
100  histname = "seedPy_";
101  seedPy = ibooker.book1D(histname, "Seed p_{y}", seedPxyzBin, seedPxyzMin, seedPxyzMax);
102  seedPy->setAxisTitle("GeV");
103  histname = "seedPz_";
104  seedPz = ibooker.book1D(histname, "Seed p_{z}", seedPxyzBin, seedPxyzMin, seedPxyzMax);
105  seedPz->setAxisTitle("GeV");
106 
107  histname = "seedPtErrOverPt_";
108  seedPtErr = ibooker.book1D(histname, "Seed p_{t}Err/p_{t}", pErrBin, pErrMin, pErrMax);
109  histname = "seedPtErrOverPtVsPhi_";
110  seedPtErrVsPhi =
111  ibooker.book2D(histname, "Seed p_{t}Err/p_{t} vs #phi", PhiBin, PhiMin, PhiMax, pErrBin, pErrMin, pErrMax);
112  seedPtErrVsPhi->setAxisTitle("rad", 2);
113  histname = "seedPtErrOverPtVsEta_";
114  seedPtErrVsEta =
115  ibooker.book2D(histname, "Seed p_{t}Err/p_{t} vs #eta", EtaBin, EtaMin, EtaMax, pErrBin, pErrMin, pErrMax);
116  histname = "seedPtErrOverPtVsPt_";
117  seedPtErrVsPt = ibooker.book2D(
118  histname, "Seed p_{t}Err/p_{t} vs p_{t}", seedPtBin / 5, seedPtMin, seedPtMax, pErrBin, pErrMin, pErrMax);
119  seedPtErrVsPt->setAxisTitle("GeV", 2);
120  histname = "seedPErrOverP_";
121  seedPErr = ibooker.book1D(histname, "Seed pErr/p", pErrBin, pErrMin, pErrMax);
122  histname = "seedPErrOverPVsPhi_";
123  seedPErrVsPhi = ibooker.book2D(histname, "Seed pErr/p vs #phi", PhiBin, PhiMin, PhiMax, pErrBin, pErrMin, pErrMax);
124  seedPErrVsPhi->setAxisTitle("rad", 2);
125  histname = "seedPErrOverPVsEta_";
126  seedPErrVsEta = ibooker.book2D(histname, "Seed pErr/p vs #eta", EtaBin, EtaMin, EtaMax, pErrBin, pErrMin, pErrMax);
127  histname = "seedPErrOverPVsPt_";
128  seedPErrVsPt =
129  ibooker.book2D(histname, "Seed pErr/p vs p_{t}", seedPtBin / 5, seedPtMin, seedPtMax, pErrBin, pErrMin, pErrMax);
130  seedPErrVsPt->setAxisTitle("GeV", 2);
131 
132  histname = "seedPxErrOverPx_";
133  seedPxErr = ibooker.book1D(histname, "Seed p_{x}Err/p_{x}", pxyzErrBin, pxyzErrMin, pxyzErrMax);
134  histname = "seedPyErrOverPy_";
135  seedPyErr = ibooker.book1D(histname, "Seed p_{y}Err/p_{y}", pxyzErrBin, pxyzErrMin, pxyzErrMax);
136  histname = "seedPzErrOverPz_";
137  seedPzErr = ibooker.book1D(histname, "Seed p_{z}Err/p_{z}", pxyzErrBin, pxyzErrMin, pxyzErrMax);
138 
139  histname = "seedPhiErr_";
140  seedPhiErr = ibooker.book1D(histname, "Seed #phi error", phiErrBin, phiErrMin, phiErrMax);
141 
142  histname = "seedEtaErr_";
143  seedEtaErr = ibooker.book1D(histname, "Seed #eta error", etaErrBin, etaErrMin, etaErrMax);
144 }
145 
147  theService->update(iSetup);
148 
149  // Take the seeds container
151  iEvent.getByToken(theSeedsCollectionLabel_, seeds);
152 
153  // if not valid, skip
154  if (!seeds.isValid())
155  return;
156 
157  for (TrajectorySeedCollection::const_iterator seed = seeds->begin(); seed != seeds->end(); ++seed) {
158  // const TrajectorySeed sd = *seed;
159 
160  // Get the Trajectory State on Det (persistent version of a TSOS) from the seed
161  PTrajectoryStateOnDet pTSOD = seed->startingState();
162 
163  // Transform it in a TrajectoryStateOnSurface
164  DetId seedDetId(pTSOD.detId());
165  const GeomDet* gdet = theService->trackingGeometry()->idToDet(seedDetId);
166  TrajectoryStateOnSurface seedTSOS =
167  trajectoryStateTransform::transientState(pTSOD, &(gdet->surface()), &*(theService)->magneticField());
169  double partialPterror =
170  errors(3, 3) * pow(seedTSOS.globalMomentum().x(), 2) + errors(4, 4) * pow(seedTSOS.globalMomentum().y(), 2);
171 
172  LogTrace(metname) << "[MuonSeedAnalyzer] Filling the histos";
173 
174  // nhits
175  LogTrace(metname) << "Number od recHits per seed: " << seed->nHits();
176  NumberOfRecHitsPerSeed->Fill(seed->nHits());
177 
178  // pt
179  LogTrace(metname) << "seed momentum: " << seedTSOS.globalMomentum().perp();
180  seedPt->Fill(seedTSOS.globalMomentum().perp());
181 
182  // px
183  LogTrace(metname) << "seed px: " << seedTSOS.globalMomentum().x();
184  seedPx->Fill(seedTSOS.globalMomentum().x());
185 
186  // py
187  LogTrace(metname) << "seed py: " << seedTSOS.globalMomentum().y();
188  seedPy->Fill(seedTSOS.globalMomentum().y());
189 
190  // pz
191  LogTrace(metname) << "seed pz: " << seedTSOS.globalMomentum().z();
192  seedPz->Fill(seedTSOS.globalMomentum().z());
193 
194  // phi
195  LogTrace(metname) << "seed phi: " << seedTSOS.globalMomentum().phi();
196  seedPhi->Fill(seedTSOS.globalMomentum().phi());
197 
198  // theta
199  LogTrace(metname) << "seed theta: " << seedTSOS.globalMomentum().theta();
200  seedTheta->Fill(seedTSOS.globalMomentum().theta());
201 
202  // eta
203  LogTrace(metname) << "seed eta: " << seedTSOS.globalMomentum().eta();
204  seedEta->Fill(seedTSOS.globalMomentum().eta());
205 
206  // pt err
207  LogTrace(metname) << "seed pt error: " << sqrt(partialPterror) / seedTSOS.globalMomentum().perp();
208  seedPtErr->Fill(sqrt(partialPterror) / seedTSOS.globalMomentum().perp());
209 
210  // ptErr/pt Vs phi
211  seedPtErrVsPhi->Fill(seedTSOS.globalMomentum().phi(), sqrt(partialPterror) / seedTSOS.globalMomentum().perp());
212  // ptErr/pt Vs eta
213  seedPtErrVsEta->Fill(seedTSOS.globalMomentum().eta(), sqrt(partialPterror) / seedTSOS.globalMomentum().perp());
214  // ptErr/pt Vs pt
215  seedPtErrVsPt->Fill(seedTSOS.globalMomentum().perp(), sqrt(partialPterror) / seedTSOS.globalMomentum().perp());
216 
217  // px err
218  LogTrace(metname) << "seed px error: " << sqrt(errors(3, 3)) / seedTSOS.globalMomentum().x();
219  seedPxErr->Fill(sqrt(errors(3, 3)) / seedTSOS.globalMomentum().x());
220 
221  // py err
222  LogTrace(metname) << "seed py error: " << sqrt(errors(4, 4)) / seedTSOS.globalMomentum().y();
223  seedPyErr->Fill(sqrt(errors(4, 4)) / seedTSOS.globalMomentum().y());
224 
225  // pz err
226  LogTrace(metname) << "seed pz error: " << sqrt(errors(5, 5)) / seedTSOS.globalMomentum().z();
227  seedPzErr->Fill(sqrt(errors(5, 5)) / seedTSOS.globalMomentum().z());
228 
229  // p err
230  LogTrace(metname) << "seed p error: "
231  << sqrt(partialPterror + errors(5, 5) * pow(seedTSOS.globalMomentum().z(), 2)) /
232  seedTSOS.globalMomentum().mag();
233  seedPErr->Fill(sqrt(partialPterror + errors(5, 5) * pow(seedTSOS.globalMomentum().z(), 2)) /
234  seedTSOS.globalMomentum().mag());
235 
236  // pErr/p Vs phi
237  seedPErrVsPhi->Fill(
238  seedTSOS.globalMomentum().phi(),
239  sqrt(partialPterror + errors(5, 5) * pow(seedTSOS.globalMomentum().z(), 2)) / seedTSOS.globalMomentum().mag());
240  // pErr/p Vs eta
241  seedPErrVsEta->Fill(
242  seedTSOS.globalMomentum().eta(),
243  sqrt(partialPterror + errors(5, 5) * pow(seedTSOS.globalMomentum().z(), 2)) / seedTSOS.globalMomentum().mag());
244  // pErr/p Vs pt
245  seedPErrVsPt->Fill(
246  seedTSOS.globalMomentum().perp(),
247  sqrt(partialPterror + errors(5, 5) * pow(seedTSOS.globalMomentum().z(), 2)) / seedTSOS.globalMomentum().mag());
248 
249  // phi err
250  LogTrace(metname) << "seed phi error: " << sqrt(seedTSOS.curvilinearError().matrix()(2, 2));
251  seedPhiErr->Fill(sqrt(seedTSOS.curvilinearError().matrix()(2, 2)));
252 
253  // eta err
254  LogTrace(metname) << "seed eta error: "
255  << sqrt(seedTSOS.curvilinearError().matrix()(1, 1)) * abs(sin(seedTSOS.globalMomentum().theta()));
256  seedEtaErr->Fill(sqrt(seedTSOS.curvilinearError().matrix()(1, 1)) * abs(sin(seedTSOS.globalMomentum().theta())));
257  }
258 }
~MuonSeedsAnalyzer() override
Destructor.
T perp() const
Definition: PV3DBase.h:69
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
T z() const
Definition: PV3DBase.h:61
const std::string metname
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T eta() const
Definition: PV3DBase.h:73
const CartesianTrajectoryError cartesianError() const
unsigned int detId() const
#define LogTrace(id)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:19
T mag() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
Definition: DetId.h:17
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
const CurvilinearTrajectoryError & curvilinearError() const
const AlgebraicSymMatrix55 & matrix() const
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
GlobalVector globalMomentum() const
void analyze(const edm::Event &, const edm::EventSetup &) override
HLT enums.
const AlgebraicSymMatrix66 & matrix() const
Definition: errors.py:1
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
Definition: Run.h:45
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
MuonSeedsAnalyzer(const edm::ParameterSet &)
Constructor.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)