CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
recoBSVTagInfoValidationAnalyzer.cc
Go to the documentation of this file.
1 #include <map>
2 #include <string>
3 #include <cmath>
4 #include <Math/Functions.h>
5 #include <Math/SVector.h>
6 #include <Math/SMatrix.h>
7 #include "TH1F.h"
8 #include "TH1D.h"
9 #include "TH2D.h"
10 #include "TMath.h"
12 
20 
24 #include "TROOT.h"
25 #include "Math/VectorUtil.h"
26 #include <TVector3.h>
27 #include <Math/GenVector/PxPyPzE4D.h>
28 #include <Math/GenVector/PxPyPzM4D.h>
30 //
31 // class decleration
32 //
33 using namespace reco;
34 using namespace std;
35 using namespace edm;
36 
38 {
39 
40 public:
41 
43 
44 private:
45 
46  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
47  virtual void endJob() override ;
48  // Member data
49 
51 
55 
58 
59  Int_t n_event;
60  Int_t rs_total_nall ;
61  Int_t rs_total_nsv ;
62  Int_t rs_total_nbv ;
63  Int_t rs_total_nbsv ;
64  Int_t rs_total_ncv ;
65  Int_t rs_total_nlv ;
66  Int_t total_nfake ;
67 
68  Int_t sr_total_nall ;
69  Int_t sr_total_nsv ;
70  Int_t sr_total_nbv ;
71  Int_t sr_total_nbsv ;
72  Int_t sr_total_ncv ;
73  Int_t sr_total_nlv ;
74  Int_t total_nmiss ;
75 
76 
77  // Bookeeping of all the histograms per category
78  void bookRecoToSim(std::string const &);
79  void bookSimToReco(std::string const &);
80 
81  // Fill all histogram per category
82  void fillRecoToSim(std::string const &, reco::Vertex const &, TrackingVertexRef const &);
83  void fillSimToReco(std::string const &, reco::VertexBaseRef const &, TrackingVertexRef const &);
84 
85  // Histogram handlers
86  std::map<std::string, MonitorElement *> HistIndex_;
87 
88  //consumes
91 
92 };
93 
94 
96 {
97  //Initialize counters
98  n_event = 0;
99  rs_total_nall = 0;
100  rs_total_nsv = 0;
101  rs_total_nbv = 0;
102  rs_total_nbsv = 0;
103  rs_total_ncv = 0;
104  rs_total_nlv = 0;
105  total_nfake = 0;
106 
107  sr_total_nall = 0;
108  sr_total_nsv = 0;
109  sr_total_nbv = 0;
110  sr_total_nbsv = 0;
111  sr_total_ncv = 0;
112  sr_total_nlv = 0;
113  total_nmiss = 0;
114 
115  // get the store
117  dqmLabel = "SVValidation/";
118  dqmStore_->setCurrentFolder(dqmLabel);
119 
120 
121  // Get the track collection
122  svInfoToken = consumes<reco::SecondaryVertexTagInfoCollection>(config.getParameter<InputTag>("svTagInfoProducer"));
123  // Name of the traking pariticle collection
124  tvToken = consumes<TrackingVertexCollection>(config.getParameter<InputTag>("trackingTruth"));
125  // Number of track categories
127 
128  // Define histogram for counting categories
129  HistIndex_["VertexClassifier"] = dqmStore_->book1D(
130  "VertexClassifier",
131  "Frequency for the different track categories",
133  -0.5,
135  );
136 
137  //--- RecoToSim
138  HistIndex_["rs_All_MatchQuality"]= dqmStore_->book1D( "rs_All_MatchQuality", "Quality of Match", 51, -0.01, 1.01 );
139  HistIndex_["rs_All_FlightDistance2d"]= dqmStore_->book1D( "rs_All_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
140  HistIndex_["rs_SecondaryVertex_FlightDistance2d"]= dqmStore_->book1D( "rs_SecondaryVertex_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
141  HistIndex_["rs_BSV_FlightDistance2d"]= dqmStore_->book1D( "rs_BSV_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
142  HistIndex_["rs_BWeakDecay_FlightDistance2d"]= dqmStore_->book1D( "rs_BWeakDecay_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
143  HistIndex_["rs_CWeakDecay_FlightDistance2d"]= dqmStore_->book1D( "rs_CWeakDecay_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
144  HistIndex_["rs_Light_FlightDistance2d"]= dqmStore_->book1D( "rs_Light_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
145 
146  HistIndex_["rs_All_nRecVtx"]= dqmStore_->book1D( "rs_All_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
147  HistIndex_["rs_SecondaryVertex_nRecVtx"]= dqmStore_->book1D( "rs_SecondaryVertex_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
148  HistIndex_["rs_BSV_nRecVtx"]= dqmStore_->book1D( "rs_BSV_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
149  HistIndex_["rs_BWeakDecay_nRecVtx"]= dqmStore_->book1D( "rs_BWeakDecay_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
150  HistIndex_["rs_CWeakDecay_nRecVtx"]= dqmStore_->book1D( "rs_CWeakDecay_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
151  HistIndex_["rs_Light_nRecVtx"]= dqmStore_->book1D( "rs_Light_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
152 
153 
154  //--- SimToReco
155  HistIndex_["sr_All_MatchQuality"]= dqmStore_->book1D( "sr_All_MatchQuality", "Quality of Match", 51, -0.01, 1.01 );
156  HistIndex_["sr_All_nRecVtx"]= dqmStore_->book1D( "sr_All_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
157  HistIndex_["sr_SecondaryVertex_nRecVtx"]= dqmStore_->book1D( "sr_SecondaryVertex_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
158  HistIndex_["sr_BSV_nRecVtx"]= dqmStore_->book1D( "sr_BSV_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
159  HistIndex_["sr_BWeakDecay_nRecVtx"]= dqmStore_->book1D( "sr_BWeakDecay_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
160  HistIndex_["sr_CWeakDecay_nRecVtx"]= dqmStore_->book1D( "sr_CWeakDecay_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
161  HistIndex_["sr_Light_nRecVtx"]= dqmStore_->book1D( "sr_Light_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
162 
163 
164  // Set the proper categories names
165  for (Int_t i = 0; i < numberVertexClassifier_; ++i)
166  HistIndex_["VertexClassifier"]->getTH1F()->GetXaxis()->SetBinLabel(i+1, VertexCategories::Names[i]);
167 
168  // book histograms
169  bookRecoToSim("rs_All");
170  bookRecoToSim("rs_SecondaryVertex");
171  bookRecoToSim("rs_BSV");
172  bookRecoToSim("rs_BWeakDecay");
173  bookRecoToSim("rs_CWeakDecay");
174  bookRecoToSim("rs_Light");
175 
176  bookSimToReco("sr_All");
177  bookSimToReco("sr_SecondaryVertex");
178  bookSimToReco("sr_BSV");
179  bookSimToReco("sr_BWeakDecay");
180  bookSimToReco("sr_CWeakDecay");
181  bookSimToReco("sr_Light");
182 }
183 
184 
186 {
187  ++n_event;
188 
189  std::cout << "*** Analyzing " << event.id() << " n_event = " << n_event << std::endl << std::endl;
190 
191  // Set the classifier for a new event
192  classifier_.newEvent(event, setup);
193 
194 
195  // Vertex collection
197  event.getByToken(svInfoToken, svTagInfoCollection);
198  // Get a constant reference to the track history associated to the classifier
199  VertexHistory const & tracer = classifier_.history();
200 
201  cout << "* Event " << n_event << " ; svTagInfoCollection->size() = " << svTagInfoCollection->size() << endl;
202 
203  int rs_nall = 0;
204  int rs_nsv = 0;
205  int rs_nbv = 0;
206  int rs_nbsv = 0;
207  int rs_ncv = 0;
208  int rs_nlv = 0;
209  int nfake = 0;
210 
211  int sr_nall = 0;
212  int sr_nsv = 0;
213  int sr_nbv = 0;
214  int sr_nbsv = 0;
215  int sr_ncv = 0;
216  int sr_nlv = 0;
217  int nmiss = 0;
218 
219  // Loop over the svTagInfo collection.
220  for (std::size_t index = 0; index < svTagInfoCollection->size(); ++index){
221 
222  reco::SecondaryVertexTagInfoRef svTagInfo(svTagInfoCollection, index);
223 
224  // Loop over the vertexes in svTagInfo
225  for ( std::size_t vindex = 0; vindex < svTagInfo->nVertices(); ++vindex ){
226 
227 
228  // Classify the vertices
229  classifier_.evaluate(svTagInfo, vindex);
230 
231  //quality of the match
232  double rs_quality = tracer.quality();
233 
234  // Fill the histogram with the categories
235  for (Int_t i = 0; i != numberVertexClassifier_; ++i) {
236 
238 
239  HistIndex_["VertexClassifier"]->Fill(i);
240  }
241  }
243 
244  HistIndex_["rs_All_MatchQuality"]->Fill( rs_quality );
245  fillRecoToSim("rs_All", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
246  HistIndex_["rs_All_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
247  rs_nall++;
248 
250 
251  fillRecoToSim("rs_SecondaryVertex", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
252  HistIndex_["rs_SecondaryVertex_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
253  rs_nsv++;
254  }
255 
257 
258  fillRecoToSim("rs_BWeakDecay", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
259  HistIndex_["rs_BWeakDecay_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
260  rs_nbv++;
261 
263 
264  fillRecoToSim("rs_BSV", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
265  HistIndex_["rs_BSV_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
266  rs_nbsv++;
267 
268  }
269  }//BWeakDecay
270 
272 
273  fillRecoToSim("rs_CWeakDecay", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
274  HistIndex_["rs_CWeakDecay_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
275  rs_ncv++;
276 
277  }
278  else {
279 
280  fillRecoToSim("rs_Light", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
281  HistIndex_["rs_Light_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
282  rs_nlv++;
283  }
284  }//end if classifier
285 
286  else {
287  cout << " VertexCategories::Fake!!" << endl;
288  nfake++;
289  }
290 
291 
292  }//end loop over vertices in svTagInfo
293 
294  }//loop over svTagInfo
295 
296  HistIndex_["rs_All_nRecVtx"]->Fill( rs_nall );
297  HistIndex_["rs_SecondaryVertex_nRecVtx"]->Fill( rs_nsv );
298  HistIndex_["rs_BWeakDecay_nRecVtx"]->Fill( rs_nbv );
299  HistIndex_["rs_BSV_nRecVtx"]->Fill( rs_nbsv );
300  HistIndex_["rs_CWeakDecay_nRecVtx"]->Fill( rs_ncv );
301  HistIndex_["rs_Light_nRecVtx"]->Fill( rs_nlv );
302  cout << endl;
303 
304  //----------------------------------------------------------------
305  // SIM TO RECO!
306 
307  // Vertex collection
309  event.getByToken(tvToken, TVCollection);
310  // Loop over the TV collection.
311  for (std::size_t index = 0; index < TVCollection->size(); ++index){
312 
313  TrackingVertexRef trackingVertex(TVCollection, index);
314 
315  classifier_.evaluate(trackingVertex);
316 
317  double sr_quality = tracer.quality();
318 
320 
321  HistIndex_["sr_All_MatchQuality"]->Fill( sr_quality );
322  fillSimToReco("sr_All", tracer.recoVertex(), trackingVertex);
323  sr_nall++;
324 
326 
327  fillSimToReco("sr_SecondaryVertex", tracer.recoVertex(), trackingVertex);
328  sr_nsv++;
329  }
330 
332 
333  fillSimToReco("sr_BWeakDecay", tracer.recoVertex(), trackingVertex);
334  sr_nbv++;
335 
337 
338  fillSimToReco("sr_BSV", tracer.recoVertex(), trackingVertex);
339  sr_nbsv++;
340  }
341 
342  }//BWeakDecay
343 
345 
346  fillSimToReco("sr_CWeakDecay", tracer.recoVertex(), trackingVertex);
347  sr_ncv++;
348  }
349 
350  else {
351 
352  fillSimToReco("sr_Light", tracer.recoVertex(), trackingVertex);
353  sr_nlv++;
354  }
355 
356  }//Reconstructed
357  else {
358  //cout << "##### Not reconstructed!" << endl;
359  nmiss++;
360  }
361 
362  }//TVCollection.size()
363 
364  HistIndex_["sr_All_nRecVtx"]->Fill( sr_nall );
365  HistIndex_["sr_SecondaryVertex_nRecVtx"]->Fill( sr_nsv );
366  HistIndex_["sr_BWeakDecay_nRecVtx"]->Fill( sr_nbv );
367  HistIndex_["sr_BSV_nRecVtx"]->Fill( sr_nbsv );
368  HistIndex_["sr_CWeakDecay_nRecVtx"]->Fill( sr_ncv );
369  HistIndex_["sr_Light_nRecVtx"]->Fill( rs_nlv );
370 
371  rs_total_nall += rs_nall;
372  rs_total_nsv += rs_nsv;
373  rs_total_nbv += rs_nbv;
374  rs_total_nbsv += rs_nbsv;
375  rs_total_ncv += rs_ncv ;
376  rs_total_nlv += rs_nlv;
377  total_nfake += nfake;
378 
379  sr_total_nall += sr_nall;
380  sr_total_nsv += sr_nsv;
381  sr_total_nbv += sr_nbv;
382  sr_total_nbsv += sr_nbsv;
383  sr_total_ncv += sr_ncv;
384  sr_total_nlv += sr_nlv;
385  total_nmiss += nmiss;
386 
387 
388 }
389 
390 
392  // Book pull histograms
393 
394  std::string name = prefix + "_Pullx";
395  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -10., 10.);
396  name = prefix + "_Pully";
397  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -10., 10.);
398  name = prefix + "_Pullz";
399  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -10., 10.);
400 
401  name = prefix + "_Resx";
402  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.05, 0.05);
403  name = prefix + "_Resy";
404  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.05, 0.05);
405  name = prefix + "_Resz";
406  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.05, 0.05);
407 
408  name = prefix + "_Chi2Norm";
409  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, 0, 10.);
410  name = prefix + "_Chi2Prob";
411  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, 0., 1.);
412 
413  name = prefix + "_nRecTrks";
414  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 501, -0.5, 500.5);
415 
416  name = prefix + "_AverageTrackWeight";
417  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.1, 1.1);
418 
419  name = prefix + "_Mass";
420  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 65, 0., 6.5);
421 
422  name = prefix + "_RecPt";
423  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 2000, 0., 1000.);
424 
425  name = prefix + "_RecEta";
426  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
427 
428  name = prefix + "_RecCharge";
429  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 21, -0.5, 20.5);
430 
431  name = prefix + "_RecTrackPt";
432  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 2000, 0., 1000.);
433 
434  name = prefix + "_RecTrackEta";
435  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
436 
437  name = prefix + "_nSimTrks";
438  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 501, -0.5, 500.5);
439 
440  name = prefix + "_SimPt";
441  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 2000, 0., 1000.);
442 
443  name = prefix + "_SimEta";
444  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
445 
446  name = prefix + "_SimCharge";
447  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 21, -0.5, 20.5);
448 
449  name = prefix + "_SimTrackPt";
450  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 500, 0., 500.);
451 
452  name = prefix + "_SimTrackEta";
453  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
454 
455 
456 }
457 
458 
460  // Book pull histograms
461 
462  std::string name = prefix + "_Pullx";
463  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -10., 10.);
464  name = prefix + "_Pully";
465  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -10., 10.);
466  name = prefix + "_Pullz";
467  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -10., 10.);
468 
469  name = prefix + "_Resx";
470  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.05, 0.05);
471  name = prefix + "_Resy";
472  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.05, 0.05);
473  name = prefix + "_Resz";
474  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.05, 0.05);
475 
476  name = prefix + "_Chi2Norm";
477  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, 0, 10.);
478  name = prefix + "_Chi2Prob";
479  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, 0., 1.);
480 
481  name = prefix + "_nRecTrks";
482  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 501, -0.5, 500.5);
483 
484  name = prefix + "_AverageTrackWeight";
485  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.1, 1.1);
486 
487  name = prefix + "_Mass";
488  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 65, 0., 6.5);
489 
490  name = prefix + "_RecPt";
491  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 2000, 0., 1000.);
492 
493  name = prefix + "_RecEta";
494  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
495 
496  name = prefix + "_RecCharge";
497  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 21, -0.5, 20.5);
498 
499  name = prefix + "_RecTrackPt";
500  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 2000, 0., 1000.);
501 
502  name = prefix + "_RecTrackEta";
503  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
504 
505  name = prefix + "_nSimTrks";
506  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 501, -0.5, 500.5);
507 
508  name = prefix + "_SimPt";
509  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 2000, 0., 1000.);
510 
511  name = prefix + "_SimEta";
512  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
513 
514  name = prefix + "_SimCharge";
515  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 21, -0.5, 20.5);
516 
517  name = prefix + "_SimTrackPt";
518  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 500, 0., 500.);
519 
520  name = prefix + "_SimTrackEta";
521  HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
522 
523 
524 }
525 
526 
528 {
529 
530  double pullx = (vertex.x() - simVertex->position().x())/vertex.xError();
531  double pully = (vertex.y() - simVertex->position().y())/vertex.yError();
532  double pullz = (vertex.z() - simVertex->position().z())/vertex.zError();
533 
534  double resx = vertex.x() - simVertex->position().x();
535  double resy = vertex.y() - simVertex->position().y();
536  double resz = vertex.z() - simVertex->position().z();
537 
538  double chi2norm = vertex.normalizedChi2();
539  double chi2prob = ChiSquaredProbability( vertex.chi2(), vertex.ndof() );
540 
541  double sum_weight = 0.;
542  double weight = 0.;
543  double tracksize = vertex.tracksSize();
544  math::XYZVector momentum;
546  int charge = 0;
547  double thePiMass = 0.13957;
548  for ( reco::Vertex::trackRef_iterator recDaughter = vertex.tracks_begin() ; recDaughter != vertex.tracks_end(); ++recDaughter) {
549 
550  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > vec;
551 
552  vec.SetPx( (**recDaughter).px() );
553  vec.SetPy( (**recDaughter).py() );
554  vec.SetPz( (**recDaughter).pz() );
555  vec.SetM(thePiMass);
556 
557  sum += vec;
558 
559  weight = vertex.trackWeight(*recDaughter);
560  sum_weight += weight;
561 
563  p = (**recDaughter).momentum();
564  momentum += p;
565 
566  charge += (*recDaughter)->charge();
567 
568  HistIndex_[prefix + "_RecTrackPt"]->Fill( (*recDaughter)->pt() );
569  HistIndex_[prefix + "_RecTrackEta"]->Fill( (*recDaughter)->eta() );
570  }//end loop to recDaughters
571  //cout << " average sum of weights = " << sum_weight/tracksize << endl;
572 
573  double mass = sum.M();
574  double pt = sqrt( momentum.Perp2() );
575  double eta = momentum.Eta();
576 
577  math::XYZVector simmomentum;
578  int simcharge = 0;
579  for ( TrackingVertex::tp_iterator simDaughter = simVertex->daughterTracks_begin(); simDaughter != simVertex->daughterTracks_end(); ++simDaughter ){
580 
582  p = (**simDaughter).momentum();
583  simmomentum += p;
584 
585  simcharge += (*simDaughter)->charge();
586 
587  HistIndex_[prefix + "_SimTrackPt"]->Fill( (*simDaughter)->pt() );
588  HistIndex_[prefix + "_SimTrackEta"]->Fill( (*simDaughter)->eta() );
589  }
590 
591  double simpt = sqrt( simmomentum.Perp2() );
592  double simeta = simmomentum.Eta();
593 
594  //cout << "[fillRecoToSim] vertex.tracksSize() = " << vertex.tracksSize() << " ; simVertex->nDaughterTracks() = " << simVertex->nDaughterTracks() << endl;
595 
596  HistIndex_[prefix + "_nRecTrks"]->Fill( vertex.tracksSize() );
597  HistIndex_[prefix + "_nSimTrks"]->Fill( simVertex->nDaughterTracks() );
598  HistIndex_[prefix + "_Pullx"]->Fill(pullx);
599  HistIndex_[prefix + "_Pully"]->Fill(pully);
600  HistIndex_[prefix + "_Pullz"]->Fill(pullz);
601  HistIndex_[prefix + "_Resx"]->Fill(resx);
602  HistIndex_[prefix + "_Resy"]->Fill(resy);
603  HistIndex_[prefix + "_Resz"]->Fill(resz);
604  HistIndex_[prefix + "_AverageTrackWeight"]->Fill( sum_weight/tracksize );
605  HistIndex_[prefix + "_Chi2Norm"]->Fill(chi2norm);
606  HistIndex_[prefix + "_Chi2Prob"]->Fill(chi2prob);
607  HistIndex_[prefix + "_RecPt"]->Fill(pt);
608  HistIndex_[prefix + "_RecEta"]->Fill(eta);
609  HistIndex_[prefix + "_RecCharge"]->Fill(charge);
610  HistIndex_[prefix + "_Mass"]->Fill(mass);
611  HistIndex_[prefix + "_SimPt"]->Fill(simpt);
612  HistIndex_[prefix + "_SimEta"]->Fill(simeta);
613  HistIndex_[prefix + "_SimCharge"]->Fill(simcharge);
614 }
615 
616 
618 {
619 
620  double pullx = (vertex->x() - simVertex->position().x())/vertex->xError();
621  double pully = (vertex->y() - simVertex->position().y())/vertex->yError();
622  double pullz = (vertex->z() - simVertex->position().z())/vertex->zError();
623 
624  double resx = vertex->x() - simVertex->position().x();
625  double resy = vertex->y() - simVertex->position().y();
626  double resz = vertex->z() - simVertex->position().z();
627 
628  double chi2norm = vertex->normalizedChi2();
629  double chi2prob = ChiSquaredProbability(vertex->chi2(), vertex->ndof());
630 
631  double sum_weight = 0.;
632  double weight = 0.;
633  double tracksize = vertex->tracksSize();
634  math::XYZVector momentum;
636  int charge = 0;
637  double thePiMass = 0.13957;
638  for ( reco::Vertex::trackRef_iterator recDaughter = vertex->tracks_begin() ; recDaughter != vertex->tracks_end(); ++recDaughter ) {
639 
640  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > vec;
641 
642  vec.SetPx( (**recDaughter).px() );
643  vec.SetPy( (**recDaughter).py() );
644  vec.SetPz( (**recDaughter).pz() );
645  vec.SetM(thePiMass);
646 
647  sum += vec;
648 
649  weight = vertex->trackWeight(*recDaughter);
650  sum_weight += weight;
651 
653  p = (**recDaughter).momentum();
654  momentum += p;
655 
656  charge += (*recDaughter)->charge();
657 
658  HistIndex_[prefix + "_RecTrackPt"]->Fill( (*recDaughter)->pt() );
659  HistIndex_[prefix + "_RecTrackEta"]->Fill( (*recDaughter)->eta() );
660 
661  }
662  //cout << " average sum of weights = " << sum_weight/tracksize << endl;
663 
664  double mass = sum.M();
665  double pt = sqrt( momentum.Perp2() );
666  double eta = momentum.Eta();
667 
668  math::XYZVector simmomentum;
669  int simcharge = 0;
670  for ( TrackingVertex::tp_iterator simDaughter = simVertex->daughterTracks_begin(); simDaughter != simVertex->daughterTracks_end(); ++simDaughter ){
671 
673  p = (**simDaughter).momentum();
674  simmomentum += p;
675 
676  simcharge += (*simDaughter)->charge();
677 
678  HistIndex_[prefix + "_SimTrackPt"]->Fill( (*simDaughter)->pt() );
679  HistIndex_[prefix + "_SimTrackEta"]->Fill( (*simDaughter)->eta() );
680  }
681 
682  double simpt = sqrt( simmomentum.Perp2() );
683  double simeta = simmomentum.Eta();
684 
685  //cout << "[fillSimToReco] vertex->tracksSize() = " << vertex->tracksSize() << " ; simVertex->nDaughterTracks() = " << simVertex->nDaughterTracks() << endl;
686 
687  HistIndex_[prefix + "_nRecTrks"]->Fill( vertex->tracksSize() );
688  HistIndex_[prefix + "_nSimTrks"]->Fill( simVertex->nDaughterTracks() );
689  HistIndex_[prefix + "_Pullx"]->Fill(pullx);
690  HistIndex_[prefix + "_Pully"]->Fill(pully);
691  HistIndex_[prefix + "_Pullz"]->Fill(pullz);
692  HistIndex_[prefix + "_Resx"]->Fill(resx);
693  HistIndex_[prefix + "_Resy"]->Fill(resy);
694  HistIndex_[prefix + "_Resz"]->Fill(resz);
695  HistIndex_[prefix + "_AverageTrackWeight"]->Fill( sum_weight/tracksize );
696  HistIndex_[prefix + "_Chi2Norm"]->Fill(chi2norm);
697  HistIndex_[prefix + "_Chi2Prob"]->Fill(chi2prob);
698  HistIndex_[prefix + "_RecPt"]->Fill(pt);
699  HistIndex_[prefix + "_RecEta"]->Fill(eta);
700  HistIndex_[prefix + "_RecCharge"]->Fill(charge);
701  HistIndex_[prefix + "_Mass"]->Fill(mass);
702  HistIndex_[prefix + "_SimPt"]->Fill(simpt);
703  HistIndex_[prefix + "_SimEta"]->Fill(simeta);
704  HistIndex_[prefix + "_SimCharge"]->Fill(simcharge);
705 
706 }
707 
708 
709 void
711 
712  std::cout << std::endl;
713  std::cout << " ====== Total Number of analyzed events: " << n_event << " ====== " << std::endl;
714  std::cout << " ====== Total Number of R2S All: " << rs_total_nall << " ====== " << std::endl;
715  std::cout << " ====== Total Number of R2S SecondaryVertex: " << rs_total_nsv << " ====== " << std::endl;
716  std::cout << " ====== Total Number of R2S BWeakDecay: " << rs_total_nbv << " ====== " << std::endl;
717  std::cout << " ====== Total Number of R2S BWeakDecay::SecondaryVertex: " << rs_total_nbsv << " ====== " << std::endl;
718  std::cout << " ====== Total Number of R2S CWeakDecay: " << rs_total_ncv << " ====== " << std::endl;
719  std::cout << " ====== Total Number of R2S Light: " << rs_total_nlv << " ====== " << std::endl;
720  std::cout << std::endl;
721  std::cout << " ====== Total Number of S2R All: " << sr_total_nall << " ====== " << std::endl;
722  std::cout << " ====== Total Number of S2R SecondaryVertex: " << sr_total_nsv << " ====== " << std::endl;
723  std::cout << " ====== Total Number of S2R BWeakDecay: " << sr_total_nbv << " ====== " << std::endl;
724  std::cout << " ====== Total Number of S2R BWeakDecay::SecondaryVertex: " << sr_total_nbsv << " ====== " << std::endl;
725  std::cout << " ====== Total Number of S2R CWeakDecay: " << sr_total_ncv << " ====== " << std::endl;
726  std::cout << " ====== Total Number of S2R Light: " << sr_total_nlv << " ====== " << std::endl;
727  std::cout << std::endl;
728  std::cout << " ====== Total Number of Fake Vertices: " << total_nfake << " ====== " << std::endl;
729 
730 }
731 
T getParameter(std::string const &) const
This class traces the simulated and generated history of a given track.
Definition: VertexHistory.h:18
int i
Definition: DBlmapReader.cc:9
VertexHistory const & history() const
Returns a reference to the vertex history used in the classification.
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
double zError() const
error on z
Definition: Vertex.h:118
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double y() const
y coordinate
Definition: Vertex.h:110
const reco::VertexBaseRef & recoVertex() const
Return a reference to the reconstructed track.
Definition: VertexHistory.h:64
void fillSimToReco(std::string const &, reco::VertexBaseRef const &, TrackingVertexRef const &)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
float trackWeight(const TrackBaseRef &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Category
Categories available to vertexes.
T sqrt(T t)
Definition: SSEVec.h:48
recoBSVTagInfoValidationAnalyzer(const edm::ParameterSet &)
VertexClassifierByProxy< reco::SecondaryVertexTagInfoCollection > classifier_
edm::EDGetTokenT< TrackingVertexCollection > tvToken
double chi2() const
chi-squares
Definition: Vertex.h:95
double z() const
y coordinate
Definition: Vertex.h:112
std::map< std::string, MonitorElement * > HistIndex_
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
float ChiSquaredProbability(double chiSquared, double nrDOF)
TH1F * getTH1F(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
bool is(Category category) const
Returns track flag for a given category.
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
double ndof() const
Definition: Vertex.h:102
const TrackingVertexRef & simVertex() const
Return the initial tracking vertex from the history.
Definition: HistoryBase.h:83
double x() const
x coordinate
Definition: Vertex.h:108
double xError() const
error on x
Definition: Vertex.h:114
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
VertexClassifierByProxy< Collection > const & evaluate(TrackingVertexRef const &vertex)
Classify the TrackingVertex in categories.
virtual void newEvent(edm::Event const &event, edm::EventSetup const &config)
Pre-process event information (for accessing reconstraction information).
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:37
tuple cout
Definition: gather_cfg.py:121
double normalizedChi2() const
chi-squared divided by n.d.o.f.
Definition: Vertex.h:104
double quality() const
Return the quality of the match.
Definition: VertexHistory.h:70
static const char *const Names[]
Name of the different categories.
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39
void fillRecoToSim(std::string const &, reco::Vertex const &, TrackingVertexRef const &)
edm::EDGetTokenT< reco::SecondaryVertexTagInfoCollection > svInfoToken
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
double yError() const
error on y
Definition: Vertex.h:116
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:34