CMS 3D CMS Logo

FSQDQM.cc
Go to the documentation of this file.
2 #include <memory>
3 
4 // DQM
6 
7 // Framework
16 
17 // Candidate handling
24 
25 // Vertex utilities
28 
29 // Other
33 
34 // Math
42 
43 // vertexing
44 
45 // Transient tracks
53 
54 // JetCorrection
56 
57 // Substructure
60 
61 // ROOT
62 #include "TLorentzVector.h"
63 
64 // STDLIB
65 #include <iostream>
66 #include <iomanip>
67 #include <cstdio>
68 #include <string>
69 #include <sstream>
70 #include <cmath>
71 
72 using namespace edm;
73 using namespace std;
74 using namespace reco;
75 using namespace trigger;
76 
77 struct SortByPt
78 
79 {
80  bool operator()(const TLorentzVector& a, const TLorentzVector& b) const { return a.Pt() > b.Pt(); }
81 };
82 
84  edm::LogInfo("FSQDQM") << " Creating FSQDQM "
85  << "\n";
86  pvs_ = consumes<edm::View<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("pvs"));
87  labelPFJet_ = iConfig.getParameter<std::string>("LabelPFJet");
88  labelCastorJet_ = iConfig.getParameter<std::string>("LabelCastorJet");
89  labelTrack_ = iConfig.getParameter<std::string>("LabelTrack");
90  tok_pfjet_ = consumes<reco::PFJetCollection>(labelPFJet_);
91  tok_track_ = consumes<reco::TrackCollection>(labelTrack_);
92  tok_castorjet_ = consumes<reco::BasicJetCollection>(labelCastorJet_);
93 }
94 
96  edm::LogInfo("FSQDQM") << " Deleting FSQDQM "
97  << "\n";
98  // do anything here that needs to be done at desctruction time
99  // (e.g. close files, deallocate resources etc.)
100 }
102  bei.setCurrentFolder("Physics/FSQ");
103  PFJetpt = bei.book1D("PFJetpt", ";p_{T}(PFJet)", 100, 0.0, 100);
104  PFJeteta = bei.book1D("PFJeteta", ";#eta(PFJet)", 50, -2.5, 2.5);
105  PFJetphi = bei.book1D("PFJetphi", ";#phi(PFJet)", 50, -3.14, 3.14);
106  PFJetMulti = bei.book1D("PFJetMulti", ";No. of PFJets", 10, -0.5, 9.5);
107  PFJetRapidity = bei.book1D("PFJetRapidity", ";PFJetRapidity", 50, -6.0, 6.0);
108  CastorJetphi = bei.book1D("CastorJetphi", ";#phi(CastorJet)", 50, -3.14, 3.14);
109  CastorJetMulti = bei.book1D("CastorJetMulti", ";No. of CastorJets", 10, -0.5, 9.5);
110  Track_HP_Phi = bei.book1D("Track_HP_Phi", ";#phi(HPtrack)", 50, -3.14, 3.14);
111  Track_HP_Eta = bei.book1D("Track_HP_Eta", ";#eta(HPtrack)", 50, -2.5, 2.5);
112  Track_HP_Pt = bei.book1D("Track_HP_Pt", ";p_{T}(HPtrack)", 500, 0.0, 50);
113  Track_HP_ptErr_over_pt = bei.book1D("Track_HP_ptErr_over_pt", ";{p_{T}Err}/p_{T}", 100, 0, 0.1);
114  Track_HP_dzvtx_over_dzerr = bei.book1D("Track_HP_dzvtx_over_dzerr", ";dZerr/dZ", 100, -10, 10);
115  Track_HP_dxyvtx_over_dxyerror = bei.book1D("Track_HP_dxyvtx_over_dxyerror", ";dxyErr/dxy", 100, -10, 10);
116  NPV = bei.book1D("NPV", ";NPV", 10, -0.5, 9.5);
117  PV_chi2 = bei.book1D("PV_chi2", ";PV_chi2", 100, 0.0, 2.0);
118  PV_d0 = bei.book1D("PV_d0", ";PV_d0", 100, -10.0, 10.0);
119  PV_numTrks = bei.book1D("PV_numTrks", ";PV_numTrks", 100, -0.5, 99.5);
120  PV_sumTrks = bei.book1D("PV_sumTrks", ";PV_sumTrks", 100, 0, 100);
121  h_ptsum_towards = bei.book1D("h_ptsum_towards", ";h_ptsum_towards", 100, 0, 100);
122  h_ptsum_transverse = bei.book1D("h_ptsum_transverse", ";h_ptsum_transverse", 100, 0, 100);
123 
124  h_ntracks = bei.book1D("h_ntracks", ";h_ntracks", 50, -0.5, 49.5);
125  h_trkptsum = bei.book1D("h_trkptsum", ";h_trkptsum", 100, 0, 100);
126  h_ptsum_away = bei.book1D("h_ptsum_away", ";h_ptsum_away", 100, 0, 100);
127  h_ntracks_towards = bei.book1D("h_ntracks_towards", ";h_ntracks_towards", 50, -0.5, 49.5);
128  h_ntracks_transverse = bei.book1D("h_ntracks_transverse", ";h_ntracks_transverse", 50, -0.5, 49.5);
129  h_ntracks_away = bei.book1D("h_ntracks_away", ";h_ntracks_away", 50, -0.5, 49.5);
130 
131  h_leadingtrkpt_ntrk_away =
132  bei.bookProfile("h_leadingtrkpt_ntrk_away", "h_leadingtrkpt_ntrk_away", 50, 0.0, 50, 0, 30, " ");
133  h_leadingtrkpt_ntrk_towards =
134  bei.bookProfile("h_leadingtrkpt_ntrk_towards", "h_leadingtrkpt_ntrk_towards", 50, 0.0, 50, 0, 30, " ");
135  h_leadingtrkpt_ntrk_transverse =
136  bei.bookProfile("h_leadingtrkpt_ntrk_transverse", "h_leadingtrkpt_ntrk_transverse", 50, 0.0, 50, 0, 30, " ");
137  h_leadingtrkpt_ptsum_away =
138  bei.bookProfile("h_leadingtrkpt_ptsum_away", "h_leadingtrkpt_ptsum_away", 50, 0.0, 50, 0, 30, " ");
139  h_leadingtrkpt_ptsum_towards =
140  bei.bookProfile("h_leadingtrkpt_ptsum_towards", "h_leadingtrkpt_ptsum_towards", 50, 0.0, 50, 0, 30, " ");
141  h_leadingtrkpt_ptsum_transverse =
142  bei.bookProfile("h_leadingtrkpt_ptsum_transverse", "h_leadingtrkpt_ptsum_transverse", 50, 0.0, 50, 0, 30, " ");
143 }
144 
145 // ------------ method called for each event ------------
146 void FSQDQM::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
147  using namespace edm;
148  using namespace std;
149  using namespace reco;
150 
151  runNumber_ = iEvent.id().run();
152  eventNumber_ = iEvent.id().event();
153  lumiNumber_ = iEvent.id().luminosityBlock();
154  bxNumber_ = iEvent.bunchCrossing();
155 
157  // if(!iEvent.getByToken(pvs_, privtxs)) return;
158  iEvent.getByToken(pvs_, privtxs);
159  double bestvz = -999.9, bestvx = -999.9, bestvy = -999.9;
160  double bestvzError = -999.9, bestvxError = -999.9, bestvyError = -999.9;
161  if (privtxs.isValid()) {
162  const reco::Vertex& pvtx = privtxs->front();
163  NPV->Fill(privtxs->size());
164  if (privtxs->begin() != privtxs->end() && !(pvtx.isFake()) && pvtx.position().Rho() <= 2. &&
165  fabs(pvtx.position().z()) <= 24) {
166  bestvz = pvtx.z();
167  bestvx = pvtx.x();
168  bestvy = pvtx.y();
169  bestvzError = pvtx.zError();
170  bestvxError = pvtx.xError();
171  bestvyError = pvtx.yError();
172  PV_chi2->Fill(pvtx.normalizedChi2());
173  PV_d0->Fill(sqrt(pvtx.x() * pvtx.x() + pvtx.y() * pvtx.y()));
174  PV_numTrks->Fill(pvtx.tracksSize());
175  double vertex_sumTrks = 0.0;
176  for (reco::Vertex::trackRef_iterator iTrack = pvtx.tracks_begin(); iTrack != pvtx.tracks_end(); iTrack++) {
177  vertex_sumTrks += (*iTrack)->pt();
178  }
179  PV_sumTrks->Fill(vertex_sumTrks);
180  }
181  }
182 
183  std::vector<Jet> recoPFJets;
184  recoPFJets.clear();
185  int nPFCHSJet = 0;
186  edm::Handle<PFJetCollection> pfjetchscoll;
187  // if(!iEvent.getByToken(tok_pfjet_, pfjetchscoll)) return;
188  iEvent.getByToken(tok_pfjet_, pfjetchscoll);
189  if (pfjetchscoll.isValid()) {
190  const reco::PFJetCollection* pfchsjets = pfjetchscoll.product();
191  reco::PFJetCollection::const_iterator pfjetchsclus = pfchsjets->begin();
192  for (pfjetchsclus = pfchsjets->begin(); pfjetchsclus != pfchsjets->end(); ++pfjetchsclus) {
193  PFJetpt->Fill(pfjetchsclus->pt());
194  PFJeteta->Fill(pfjetchsclus->eta());
195  PFJetphi->Fill(pfjetchsclus->phi());
196  PFJetRapidity->Fill(pfjetchsclus->rapidity());
197  nPFCHSJet++;
198  }
199  PFJetMulti->Fill(nPFCHSJet);
200  }
201 
202  std::vector<Jet> recoCastorJets;
203  recoCastorJets.clear();
205  // if(!iEvent.getByToken(tok_castorjet_, castorJets)) return;
206  iEvent.getByToken(tok_castorjet_, castorJets);
207  if (castorJets.isValid()) {
208  for (unsigned ijet = 0; ijet < castorJets->size(); ijet++) {
209  recoCastorJets.push_back((*castorJets)[ijet]);
210  }
211  for (unsigned ijet = 0; ijet < recoCastorJets.size(); ijet++) {
212  // cout<<recoCastorJets[ijet].pt()<<endl;
213  CastorJetphi->Fill(recoCastorJets[ijet].phi());
214 
215  CastorJetMulti->Fill(recoCastorJets.size());
216  }
217  }
219  // if(!iEvent.getByToken(tok_track_, itracks)) return;
220  iEvent.getByToken(tok_track_, itracks);
221  if (itracks.isValid()) {
223  std::vector<TLorentzVector> T_trackRec_P4;
224 
225  int ntracks = 0;
226  int ntracks_towards = 0;
227  int ntracks_transverse = 0;
228  int ntracks_away = 0;
229  float ptsum = 0;
230  float dphi = 0;
231  float ptsum_towards = 0;
232  float ptsum_transverse = 0;
233  float ptsum_away = 0;
234 
235  T_trackRec_P4.clear();
236  for (reco::TrackCollection::const_iterator iT = itracks->begin(); iT != itracks->end(); ++iT) {
237  if (iT->quality(hiPurity)) {
238  math::XYZPoint bestvtx(bestvx, bestvy, bestvz);
239  double dzvtx = iT->dz(bestvtx);
240  double dxyvtx = iT->dxy(bestvtx);
241  double dzerror = sqrt(iT->dzError() * iT->dzError() + bestvzError * bestvzError);
242  double dxyerror = sqrt(iT->d0Error() * iT->d0Error() + bestvxError * bestvyError);
243  if ((iT->ptError()) / iT->pt() < 0.05 && dzvtx < 3.0 && dxyvtx < 3.0) {
244  TLorentzVector trk;
245  trk.SetPtEtaPhiE(iT->pt(), iT->eta(), iT->phi(), iT->p());
246  T_trackRec_P4.push_back(trk);
247  Track_HP_Eta->Fill(iT->eta());
248  Track_HP_Phi->Fill(iT->phi());
249  Track_HP_Pt->Fill(iT->pt());
250  Track_HP_ptErr_over_pt->Fill((iT->ptError()) / iT->pt());
251  Track_HP_dzvtx_over_dzerr->Fill(dzvtx / dzerror);
252  Track_HP_dxyvtx_over_dxyerror->Fill(dxyvtx / dxyerror);
253  }
254  }
255  }
256 
257  float highest_pt_track = -999;
258  int index = -999;
259  for (unsigned int k = 0; k < T_trackRec_P4.size(); k++) {
260  if (T_trackRec_P4.at(k).Pt() > highest_pt_track) {
261  highest_pt_track = T_trackRec_P4.at(k).Pt();
262  index = k;
263  }
264  }
265  unsigned int finalid = abs(index);
266  // if(T_trackRec_P4.at(index).Pt()!=0.){
267  if (finalid < T_trackRec_P4.size()) {
268  // std::sort(T_trackRec_P4.begin(), T_trackRec_P4.end(), SortByPt());
269  for (unsigned int itrk = 0; itrk < T_trackRec_P4.size(); itrk++) {
270  ++ntracks;
271  ptsum = ptsum + T_trackRec_P4.at(itrk).Pt();
272  dphi = deltaPhi(T_trackRec_P4.at(itrk).Phi(), T_trackRec_P4.at(index).Phi());
273  if (fabs(dphi) < 1.05) {
274  ++ntracks_towards;
275  ptsum_towards = ptsum_towards + T_trackRec_P4.at(itrk).Pt();
276  }
277  if (fabs(dphi) > 1.05 && fabs(dphi) < 2.09) {
278  ++ntracks_transverse;
279  ptsum_transverse = ptsum_transverse + T_trackRec_P4.at(itrk).Pt();
280  }
281  if (fabs(dphi) > 2.09) {
282  ++ntracks_away;
283  ptsum_away = ptsum_away + T_trackRec_P4.at(itrk).Pt();
284  }
285  }
286 
287  h_ntracks->Fill(ntracks);
288  h_trkptsum->Fill(ptsum);
289  h_ptsum_towards->Fill(ptsum_towards);
290  h_ptsum_transverse->Fill(ptsum_transverse);
291  h_ptsum_away->Fill(ptsum_away);
292  h_ntracks_towards->Fill(ntracks_towards);
293  h_ntracks_transverse->Fill(ntracks_transverse);
294  h_ntracks_away->Fill(ntracks_away);
295 
296  if (!T_trackRec_P4.empty()) {
297  h_leadingtrkpt_ntrk_towards->Fill(T_trackRec_P4.at(index).Pt(), ntracks_towards / 8.37);
298  h_leadingtrkpt_ntrk_transverse->Fill(T_trackRec_P4.at(index).Pt(), ntracks_transverse / 8.37);
299  h_leadingtrkpt_ntrk_away->Fill(T_trackRec_P4.at(index).Pt(), ntracks_away / 8.37);
300  h_leadingtrkpt_ptsum_towards->Fill(T_trackRec_P4.at(index).Pt(), ptsum_towards / 8.37);
301  h_leadingtrkpt_ptsum_transverse->Fill(T_trackRec_P4.at(index).Pt(), ptsum_transverse / 8.37);
302  h_leadingtrkpt_ptsum_away->Fill(T_trackRec_P4.at(index).Pt(), ptsum_away / 8.37);
303  }
304  }
305  }
306 } //analyze
307 
308 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
309 
310 //define this as a plug-in
311 //DEFINE_FWK_MODULE(FSQDQM);
312 
313 // LocalWords: TH1F ptsum fs ntracks
reco::Vertex::trackRef_iterator
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38
MessageLogger.h
CompositeCandidate.h
TrackerGeometry.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
CATopJetTagInfo.h
FSQDQM::bookHistograms
void bookHistograms(DQMStore::IBooker &bei, edm::Run const &, edm::EventSetup const &) override
Definition: FSQDQM.cc:101
edm::Run
Definition: Run.h:45
reco::Vertex::z
double z() const
z coordinate
Definition: Vertex.h:120
JetCorrector.h
LuminosityBlock.h
edm
HLT enums.
Definition: AlignableModifier.h:19
SortByPt::operator()
bool operator()(const TLorentzVector &a, const TLorentzVector &b) const
Definition: FSQDQM.cc:80
edm::LogInfo
Definition: MessageLogger.h:254
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
TrackerRecoGeometryRecord.h
reco::TrackBase::TrackQuality
TrackQuality
track quality
Definition: TrackBase.h:150
DQMStore.h
reco::Vertex::position
const Point & position() const
position
Definition: Vertex.h:114
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
TransientTrack.h
edm::Handle
Definition: AssociativeIterator.h:50
CandMatchMap.h
FileInPath.h
CandidateFwd.h
deltaR.h
Track.h
reco::Vertex::isFake
bool isFake() const
Definition: Vertex.h:76
reco::Vertex::xError
double xError() const
error on x
Definition: Vertex.h:124
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
Service.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
EventID.h
FSQDQM::FSQDQM
FSQDQM(const edm::ParameterSet &ps)
Definition: FSQDQM.cc:83
reco::Vertex::tracks_end
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:73
Run.h
dqm::implementation::IBooker::bookProfile
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:322
dqmdumpme.k
k
Definition: dqmdumpme.py:60
b
double b
Definition: hdecay.h:118
RefToBase.h
reco::Vertex::zError
double zError() const
error on z
Definition: Vertex.h:128
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
CompositeCandidateFwd.h
TrackerDigiGeometryRecord.h
FSQDQM.h
TransientTrackBuilder.h
edm::ParameterSet
Definition: ParameterSet.h:36
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
a
double a
Definition: hdecay.h:119
reco::Vertex::tracks_begin
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:71
reco::Vertex::x
double x() const
x coordinate
Definition: Vertex.h:116
CATopJetHelper.h
LorentzVector.h
reco::Vertex::tracksSize
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:69
iEvent
int iEvent
Definition: GenABIO.cc:224
RecoPFJets_cff.recoPFJets
recoPFJets
Definition: RecoPFJets_cff.py:45
SortByPt
Definition: FSQDQM.cc:77
edm::EventSetup
Definition: EventSetup.h:57
TransientTrackRecord.h
FSQDQM::~FSQDQM
~FSQDQM() override
Definition: FSQDQM.cc:95
reco::TrackBase::qualityByName
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
VertexFwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
std
Definition: JetResolutionObject.h:76
reco::Vertex::y
double y() const
y coordinate
Definition: Vertex.h:118
reco::PFJetCollection
std::vector< PFJet > PFJetCollection
collection of PFJet objects
Definition: PFJetCollection.h:14
DetId.h
reco::Vertex::normalizedChi2
double normalizedChi2() const
chi-squared divided by n.d.o.f.
Definition: Vertex.h:112
FSQDQM::analyze
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
Definition: FSQDQM.cc:146
Point3D.h
GlobalVector.h
EventSetup.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
trigger
Definition: HLTPrescaleTableCond.h:8
AssociationVector.h
OverlapChecker.h
reco::Vertex::yError
double yError() const
error on y
Definition: Vertex.h:126
Candidate.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
MuonGeometryRecord.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
Vector3D.h
edm::InputTag
Definition: InputTag.h:15
sistrip::runNumber_
static const char runNumber_[]
Definition: ConstantsForDqm.h:33
reco::Vertex
Definition: Vertex.h:35
deltaPhi.h
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98