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&);
47  virtual void endJob() ;
48  // Member data
49 
51 
55 
57  std::string dqmLabel;
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 };
89 
90 
92 {
93  //Initialize counters
94  n_event = 0;
95  rs_total_nall = 0;
96  rs_total_nsv = 0;
97  rs_total_nbv = 0;
98  rs_total_nbsv = 0;
99  rs_total_ncv = 0;
100  rs_total_nlv = 0;
101  total_nfake = 0;
102 
103  sr_total_nall = 0;
104  sr_total_nsv = 0;
105  sr_total_nbv = 0;
106  sr_total_nbsv = 0;
107  sr_total_ncv = 0;
108  sr_total_nlv = 0;
109  total_nmiss = 0;
110 
111  // get the store
113  dqmLabel = "SVValidation/";
115 
116 
117  // Get the track collection
118  svTagInfoProducer_ = config.getUntrackedParameter<edm::InputTag> ( "svTagInfoProducer" );
119 
120  // Name of the traking pariticle collection
121  trackingTruth_ = config.getUntrackedParameter<edm::InputTag> ( "trackingTruth" );
122 
123  // Number of track categories
125 
126  // Define histogram for counting categories
127  HistIndex_["VertexClassifier"] = dqmStore_->book1D(
128  "VertexClassifier",
129  "Frequency for the different track categories",
130  numberVertexClassifier_,
131  -0.5,
132  numberVertexClassifier_ - 0.5
133  );
134 
135  //--- RecoToSim
136  HistIndex_["rs_All_MatchQuality"]= dqmStore_->book1D( "rs_All_MatchQuality", "Quality of Match", 51, -0.01, 1.01 );
137  HistIndex_["rs_All_FlightDistance2d"]= dqmStore_->book1D( "rs_All_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
138  HistIndex_["rs_SecondaryVertex_FlightDistance2d"]= dqmStore_->book1D( "rs_SecondaryVertex_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
139  HistIndex_["rs_BSV_FlightDistance2d"]= dqmStore_->book1D( "rs_BSV_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
140  HistIndex_["rs_BWeakDecay_FlightDistance2d"]= dqmStore_->book1D( "rs_BWeakDecay_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
141  HistIndex_["rs_CWeakDecay_FlightDistance2d"]= dqmStore_->book1D( "rs_CWeakDecay_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
142  HistIndex_["rs_Light_FlightDistance2d"]= dqmStore_->book1D( "rs_Light_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
143 
144  HistIndex_["rs_All_nRecVtx"]= dqmStore_->book1D( "rs_All_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
145  HistIndex_["rs_SecondaryVertex_nRecVtx"]= dqmStore_->book1D( "rs_SecondaryVertex_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
146  HistIndex_["rs_BSV_nRecVtx"]= dqmStore_->book1D( "rs_BSV_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
147  HistIndex_["rs_BWeakDecay_nRecVtx"]= dqmStore_->book1D( "rs_BWeakDecay_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
148  HistIndex_["rs_CWeakDecay_nRecVtx"]= dqmStore_->book1D( "rs_CWeakDecay_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
149  HistIndex_["rs_Light_nRecVtx"]= dqmStore_->book1D( "rs_Light_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
150 
151 
152  //--- SimToReco
153  HistIndex_["sr_All_MatchQuality"]= dqmStore_->book1D( "sr_All_MatchQuality", "Quality of Match", 51, -0.01, 1.01 );
154  HistIndex_["sr_All_nRecVtx"]= dqmStore_->book1D( "sr_All_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
155  HistIndex_["sr_SecondaryVertex_nRecVtx"]= dqmStore_->book1D( "sr_SecondaryVertex_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
156  HistIndex_["sr_BSV_nRecVtx"]= dqmStore_->book1D( "sr_BSV_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
157  HistIndex_["sr_BWeakDecay_nRecVtx"]= dqmStore_->book1D( "sr_BWeakDecay_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
158  HistIndex_["sr_CWeakDecay_nRecVtx"]= dqmStore_->book1D( "sr_CWeakDecay_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
159  HistIndex_["sr_Light_nRecVtx"]= dqmStore_->book1D( "sr_Light_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
160 
161 
162  // Set the proper categories names
163  for (Int_t i = 0; i < numberVertexClassifier_; ++i)
164  HistIndex_["VertexClassifier"]->getTH1F()->GetXaxis()->SetBinLabel(i+1, VertexCategories::Names[i]);
165 
166  // book histograms
167  bookRecoToSim("rs_All");
168  bookRecoToSim("rs_SecondaryVertex");
169  bookRecoToSim("rs_BSV");
170  bookRecoToSim("rs_BWeakDecay");
171  bookRecoToSim("rs_CWeakDecay");
172  bookRecoToSim("rs_Light");
173 
174  bookSimToReco("sr_All");
175  bookSimToReco("sr_SecondaryVertex");
176  bookSimToReco("sr_BSV");
177  bookSimToReco("sr_BWeakDecay");
178  bookSimToReco("sr_CWeakDecay");
179  bookSimToReco("sr_Light");
180 }
181 
182 
184 {
185  ++n_event;
186 
187  std::cout << "*** Analyzing " << event.id() << " n_event = " << n_event << std::endl << std::endl;
188 
189  // Set the classifier for a new event
190  classifier_.newEvent(event, setup);
191 
192 
193  // Vertex collection
195  event.getByLabel(svTagInfoProducer_, svTagInfoCollection);
196 
197  // Get a constant reference to the track history associated to the classifier
198  VertexHistory const & tracer = classifier_.history();
199 
200  cout << "* Event " << n_event << " ; svTagInfoCollection->size() = " << svTagInfoCollection->size() << endl;
201 
202  int rs_nall = 0;
203  int rs_nsv = 0;
204  int rs_nbv = 0;
205  int rs_nbsv = 0;
206  int rs_ncv = 0;
207  int rs_nlv = 0;
208  int nfake = 0;
209 
210  int sr_nall = 0;
211  int sr_nsv = 0;
212  int sr_nbv = 0;
213  int sr_nbsv = 0;
214  int sr_ncv = 0;
215  int sr_nlv = 0;
216  int nmiss = 0;
217 
218  // Loop over the svTagInfo collection.
219  for (std::size_t index = 0; index < svTagInfoCollection->size(); ++index){
220 
221  reco::SecondaryVertexTagInfoRef svTagInfo(svTagInfoCollection, index);
222 
223  // Loop over the vertexes in svTagInfo
224  for ( std::size_t vindex = 0; vindex < svTagInfo->nVertices(); ++vindex ){
225 
226 
227  // Classify the vertices
228  classifier_.evaluate(svTagInfo, vindex);
229 
230  //quality of the match
231  double rs_quality = tracer.quality();
232 
233  // Fill the histogram with the categories
234  for (Int_t i = 0; i != numberVertexClassifier_; ++i) {
235 
237 
238  HistIndex_["VertexClassifier"]->Fill(i);
239  }
240  }
242 
243  HistIndex_["rs_All_MatchQuality"]->Fill( rs_quality );
244  fillRecoToSim("rs_All", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
245  HistIndex_["rs_All_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
246  rs_nall++;
247 
249 
250  fillRecoToSim("rs_SecondaryVertex", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
251  HistIndex_["rs_SecondaryVertex_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
252  rs_nsv++;
253  }
254 
256 
257  fillRecoToSim("rs_BWeakDecay", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
258  HistIndex_["rs_BWeakDecay_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
259  rs_nbv++;
260 
262 
263  fillRecoToSim("rs_BSV", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
264  HistIndex_["rs_BSV_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
265  rs_nbsv++;
266 
267  }
268  }//BWeakDecay
269 
271 
272  fillRecoToSim("rs_CWeakDecay", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
273  HistIndex_["rs_CWeakDecay_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
274  rs_ncv++;
275 
276  }
277  else {
278 
279  fillRecoToSim("rs_Light", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
280  HistIndex_["rs_Light_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
281  rs_nlv++;
282  }
283  }//end if classifier
284 
285  else {
286  cout << " VertexCategories::Fake!!" << endl;
287  nfake++;
288  }
289 
290 
291  }//end loop over vertices in svTagInfo
292 
293  }//loop over svTagInfo
294 
295  HistIndex_["rs_All_nRecVtx"]->Fill( rs_nall );
296  HistIndex_["rs_SecondaryVertex_nRecVtx"]->Fill( rs_nsv );
297  HistIndex_["rs_BWeakDecay_nRecVtx"]->Fill( rs_nbv );
298  HistIndex_["rs_BSV_nRecVtx"]->Fill( rs_nbsv );
299  HistIndex_["rs_CWeakDecay_nRecVtx"]->Fill( rs_ncv );
300  HistIndex_["rs_Light_nRecVtx"]->Fill( rs_nlv );
301  cout << endl;
302 
303  //----------------------------------------------------------------
304  // SIM TO RECO!
305 
306  // Vertex collection
308  event.getByLabel(trackingTruth_, TVCollection);
309 
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 
527 void recoBSVTagInfoValidationAnalyzer::fillRecoToSim(std::string const & prefix, reco::Vertex const & vertex, TrackingVertexRef const & simVertex)
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 
617 void recoBSVTagInfoValidationAnalyzer::fillSimToReco(std::string const & prefix, reco::VertexBaseRef const & vertex, TrackingVertexRef const & simVertex)
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 
This class traces the simulated and generated history of a given track.
Definition: VertexHistory.h:17
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
virtual void analyze(const edm::Event &, const edm::EventSetup &)
VertexHistory const & history() const
Returns a reference to the vertex history used in the classification.
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:45
double zError() const
error on z
Definition: Vertex.h:105
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double y() const
y coordinate
Definition: Vertex.h:97
const reco::VertexBaseRef & recoVertex() const
Return a reference to the reconstructed track.
Definition: VertexHistory.h:62
T eta() const
double charge(const std::vector< uint8_t > &Ampls)
void fillSimToReco(std::string const &, reco::VertexBaseRef const &, TrackingVertexRef const &)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
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:46
recoBSVTagInfoValidationAnalyzer(const edm::ParameterSet &)
VertexClassifierByProxy< reco::SecondaryVertexTagInfoCollection > classifier_
double chi2() const
chi-squares
Definition: Vertex.h:82
double z() const
y coordinate
Definition: Vertex.h:99
std::map< std::string, MonitorElement * > HistIndex_
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:89
const TrackingVertexRef & simVertex() const
Return the initial tracking vertex from the history.
Definition: HistoryBase.h:83
double x() const
x coordinate
Definition: Vertex.h:95
double xError() const
error on x
Definition: Vertex.h:101
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
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).
tuple mass
Definition: scaleCards.py:27
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:38
tuple cout
Definition: gather_cfg.py:121
double normalizedChi2() const
chi-squared divided by n.d.o.f.
Definition: Vertex.h:91
static const char * Names[]
Name of the different categories.
double quality() const
Return the quality of the match.
Definition: VertexHistory.h:68
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:40
void fillRecoToSim(std::string const &, reco::Vertex const &, TrackingVertexRef const &)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
double yError() const
error on y
Definition: Vertex.h:103
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:35