CMS 3D CMS Logo

BPHHistoSpecificDecay.cc
Go to the documentation of this file.
2 
4 
6 
8 
11 
14 
16 
18 #include "TMath.h"
19 #include "Math/VectorUtil.h"
20 #include "TVector3.h"
21 
22 #include <TH1.h>
23 #include <TFile.h>
24 
25 #include <set>
26 #include <string>
27 #include <iostream>
28 #include <fstream>
29 #include <cmath>
30 
31 using namespace std;
32 
33 #define SET_LABEL(NAME,PSET) ( NAME = PSET.getParameter<string>( #NAME ) )
34 // SET_LABEL(xyz,ps);
35 // is equivalent to
36 // xyz = ps.getParameter<string>( "xyx" )
37 
38 class BPHUserData {
39  public:
40  template<class T>
41  static const T* get( const pat::CompositeCandidate& cand,
42  const string& name ) {
43  if ( cand.hasUserData( name ) ) return cand.userData<T>( name );
44  return nullptr;
45  }
46  template<class T>
47  static const T* getByRef( const pat::CompositeCandidate& cand,
48  const string& name ) {
49  if ( cand.hasUserData( name ) ) {
50  typedef edm::Ref< std::vector<T> > objRef;
51  const objRef* ref = cand.userData<objRef>( name );
52  if ( ref == nullptr ) return nullptr;
53  if ( ref->isNull() ) return nullptr;
54  return ref->get();
55  }
56  return nullptr;
57  }
58 };
59 
60 
61 class BPHDaughters {
62  public:
63  static vector<const reco::Candidate*> get(
64  const pat::CompositeCandidate& cand, float massMin, float massMax ) {
65  int i;
66  int n = cand.numberOfDaughters();
67  vector<const reco::Candidate*> v;
68  v.reserve( n );
69  for ( i = 0; i < n; ++i ) {
70  const reco::Candidate* dptr = cand.daughter( i );
71  float mass = dptr->mass();
72  if ( ( mass > massMin ) && ( mass < massMax ) ) v.push_back( dptr );
73  }
74  return v;
75  }
76 };
77 
78 
80  public:
81  BPHSoftMuonSelect( int cutTrackerLayers = 5,
82  int cutPixelLayers = 0,
83  float maxDxy = 0.3,
84  float maxDz = 20.0,
85  bool goodMuon = true ,
86  bool highPurity = true ):
87  cutTL ( cutTrackerLayers ),
88  cutPL ( cutPixelLayers ),
89  maxXY ( maxDxy ),
90  maxZ ( maxDz ),
91  gM ( goodMuon ),
92  hP ( highPurity ) {}
93  bool accept( const reco::Candidate& cand,
94  const reco::Vertex* pv ) const {
95  const pat::Muon* p = reinterpret_cast<const pat::Muon*>( &cand );
96  if ( p == nullptr ) return false;
97  if ( gM &&
98  !muon::isGoodMuon( *p, muon::TMOneStationTight ) ) return false;
99  if ( p->innerTrack()->hitPattern().trackerLayersWithMeasurement() <= cutTL )
100  return false;
101  if ( p->innerTrack()->hitPattern(). pixelLayersWithMeasurement() <= cutPL )
102  return false;
103  if ( hP &&
104  !p->innerTrack()->quality( reco::TrackBase::highPurity ) )
105  return false;
106  if ( pv == nullptr ) return true;
107  const reco::Vertex::Point& pos = pv->position();
108  if ( fabs( p->innerTrack()->dxy( pos ) ) >= maxXY )
109  return false;
110  if ( fabs( p->innerTrack()->dz ( pos ) ) >= maxZ )
111  return false;
112  return true;
113  }
114  private:
115  const reco::Vertex* pv;
116  int cutTL;
117  int cutPL;
118  float maxXY;
119  float maxZ;
120  bool gM;
121  bool hP;
122 };
123 
124 
126  public:
127  BPHDaughterSelect( float ptMinLoose,
128  float ptMinTight,
129  float etaMaxLoose,
130  float etaMaxTight,
131  const BPHSoftMuonSelect*
132  softMuonselector = nullptr ): pLMin( ptMinLoose ),
133  pTMin( ptMinTight ),
134  eLMax( etaMaxLoose ),
135  eTMax( etaMaxTight ),
136  sms( softMuonselector ) {
137  }
139  const reco::Vertex* pv = nullptr ) const override {
140  const reco::Candidate* dptr0 = cand.daughter( 0 );
141  const reco::Candidate* dptr1 = cand.daughter( 1 );
142  if ( dptr0 == nullptr ) return false;
143  if ( dptr1 == nullptr ) return false;
144  float pt0 = dptr0->pt();
145  float pt1 = dptr1->pt();
146  if ( ( pt0 < pLMin ) || ( pt1 < pLMin ) ) return false;
147  if ( ( pt0 < pTMin ) && ( pt1 < pTMin ) ) return false;
148  float eta0 = fabs( dptr0->eta() );
149  float eta1 = fabs( dptr1->eta() );
150  if ( ( eLMax > 0 ) &&
151  ( ( eta0 > eLMax ) || ( eta1 > eLMax ) ) ) return false;
152  if ( ( eTMax > 0 ) &&
153  ( ( eta0 > eTMax ) && ( eta1 > eTMax ) ) ) return false;
154  if ( sms != nullptr ) {
155  const reco::Vertex* pvtx = BPHUserData::getByRef
156  <reco::Vertex>( cand, "primaryVertex" );
157  if ( pvtx == nullptr ) return false;
158  if ( !sms->accept( *dptr0, pvtx ) ) return false;
159  if ( !sms->accept( *dptr1, pvtx ) ) return false;
160  }
161  return true;
162  }
163  private:
164  float pLMin;
165  float pTMin;
166  float eLMax;
167  float eTMax;
169 };
170 
171 
173  public:
174  BPHCompositeBasicSelect( float massMin,
175  float massMax,
176  float ptMin = -1.0,
177  float etaMax = -1.0,
178  float rapidityMax = -1.0 ): mMin( massMin ),
179  mMax( massMax ),
180  pMin( ptMin ),
181  eMax( etaMax ),
182  yMax( rapidityMax ) {
183  }
185  const reco::Vertex* pv = nullptr ) const override {
186  if ( ( ( mMin > 0 ) && ( mMax < 0 ) ) ||
187  ( ( mMin < 0 ) && ( mMax > 0 ) ) ||
188  ( ( mMin > 0 ) && ( mMax > 0 ) && ( mMin < mMax ) ) ) {
189  float mass = cand.mass();
190  if ( mass < mMin ) return false;
191  if ( ( mMax > 0 ) &&
192  ( mass > mMax ) ) return false;
193  }
194  if ( cand. pt() < pMin ) return false;
195  if ( ( eMax > 0 ) &&
196  ( fabs( cand. eta() ) > eMax ) ) return false;
197  if ( ( yMax > 0 ) &&
198  ( fabs( cand.rapidity() ) > yMax ) ) return false;
199  return true;
200  }
201 
202  private:
203  float mMin;
204  float mMax;
205  float pMin;
206  float eMax;
207  float yMax;
208 };
209 
210 
212  public:
213  BPHFittedBasicSelect( float massMin,
214  float massMax,
215  float ptMin = -1.0,
216  float etaMax = -1.0,
217  float rapidityMax = -1.0 ): mMin( massMin ),
218  mMax( massMax ),
219  pMin( ptMin ),
220  eMax( etaMax ),
221  rMax( rapidityMax ) {
222  }
224  const reco::Vertex* pv = nullptr ) const override {
225  if ( !cand.hasUserFloat( "fitMass" ) ) return false;
226  float mass = cand.userFloat( "fitMass" );
227  if ( ( ( mMin > 0 ) && ( mMax < 0 ) ) ||
228  ( ( mMin < 0 ) && ( mMax > 0 ) ) ||
229  ( ( mMin > 0 ) && ( mMax > 0 ) && ( mMin < mMax ) ) ) {
230  if ( mass < mMin ) return false;
231  if ( ( mMax > 0 ) &&
232  ( mass > mMax ) ) return false;
233  }
235  < Vector3DBase<float,GlobalTag> >( cand, "fitMomentum" );
236  if ( fmom == nullptr ) return false;
237  if ( pMin > 0 ) {
238  if ( fmom->transverse() < pMin ) return false;
239  }
240  if ( eMax > 0 ) {
241  if ( fabs( fmom->eta() ) > eMax ) return false;
242  }
243  if ( rMax > 0 ) {
244  float x = fmom->x();
245  float y = fmom->y();
246  float z = fmom->z();
247  float e = sqrt( ( x * x ) + ( y * y ) + ( z * z ) + ( mass * mass ) );
248  float r = log( ( e + z ) / ( e - z ) ) / 2;
249  if ( fabs( r ) > rMax ) return false;
250  }
251  return true;
252  }
253 
254  private:
255  float mMin;
256  float mMax;
257  float pMin;
258  float eMax;
259  float rMax;
260 };
261 
262 
264  public:
265  BPHCompositeVertexSelect( float probMin,
266  float cosMin = -1.0,
267  float sigMin = -1.0 ): pMin( probMin ),
268  cMin( cosMin ),
269  sMin( sigMin ) {
270  }
272  const reco::Vertex* pvtx = nullptr ) const override {
273  const reco::Vertex* svtx = BPHUserData::get
274  <reco::Vertex>( cand, "vertex" );
275  if ( svtx == nullptr ) return false;
276  if ( pvtx == nullptr ) return false;
277  if ( pMin > 0 ) {
278  if ( ChiSquaredProbability( svtx->chi2(),
279  svtx->ndof() ) < pMin ) return false;
280  }
281  if ( ( cMin > 0 ) || ( sMin > 0 ) ) {
282  TVector3 disp( svtx->x() - pvtx->x(),
283  svtx->y() - pvtx->y(),
284  0 );
285  TVector3 cmom( cand.px(), cand.py(), 0 );
286  float cosAlpha = disp.Dot( cmom ) / ( disp.Perp() * cmom.Perp() );
287  if ( cosAlpha < cMin ) return false;
288  if ( sMin < 0 ) return true;
289  float mass = cand.mass();
290  AlgebraicVector3 vmom( cand.px(), cand.py(), 0 );
291  VertexDistanceXY vdistXY;
292  Measurement1D distXY = vdistXY.distance( *svtx, *pvtx );
293  double ctauPV = distXY.value() * cosAlpha * mass / cmom.Perp();
294  GlobalError sve = svtx->error();
295  GlobalError pve = pvtx->error();
296  AlgebraicSymMatrix33 vXYe = sve.matrix() + pve.matrix();
297  double ctauErrPV = sqrt( ROOT::Math::Similarity( vmom, vXYe ) ) * mass /
298  cmom.Perp2();
299  if ( ( ctauPV / ctauErrPV ) < sMin ) return false;
300  }
301  return true;
302  }
303 
304  private:
305  float pMin;
306  float cMin;
307  float sMin;
308 };
309 
310 
312  public:
313  BPHFittedVertexSelect( float probMin,
314  float cosMin = -1.0,
315  float sigMin = -1.0 ): pMin( probMin ),
316  cMin( cosMin ),
317  sMin( sigMin ) {
318  }
320  const reco::Vertex* pvtx ) const override {
321  const reco::Vertex* svtx = BPHUserData::get
322  <reco::Vertex>( cand, "fitVertex" );
323  if ( svtx == nullptr ) return false;
324  if ( pMin > 0 ) {
325  if ( ChiSquaredProbability( svtx->chi2(),
326  svtx->ndof() ) < pMin ) return false;
327  }
328  if ( ( cMin > 0 ) || ( sMin > 0 ) ) {
329  TVector3 disp( svtx->x() - pvtx->x(),
330  svtx->y() - pvtx->y(),
331  0 );
333  < Vector3DBase<float,GlobalTag> >( cand, "fitMomentum" );
334  if ( fmom == nullptr ) return false;
335  TVector3 cmom( fmom->x(), fmom->y(), 0 );
336  float cosAlpha = disp.Dot( cmom ) / ( disp.Perp() * cmom.Perp() );
337  if ( cosAlpha < cMin ) return false;
338  if ( sMin < 0 ) return true;
339  if ( !cand.hasUserFloat( "fitMass" ) ) return false;
340  float mass = cand.userFloat( "fitMass" );
341  AlgebraicVector3 vmom( fmom->x(), fmom->y(), 0 );
342  VertexDistanceXY vdistXY;
343  Measurement1D distXY = vdistXY.distance( *svtx, *pvtx );
344  double ctauPV = distXY.value() * cosAlpha * mass / cmom.Perp();
345  GlobalError sve = svtx->error();
346  GlobalError pve = pvtx->error();
347  AlgebraicSymMatrix33 vXYe = sve.matrix() + pve.matrix();
348  double ctauErrPV = sqrt( ROOT::Math::Similarity( vmom, vXYe ) ) * mass /
349  cmom.Perp2();
350  if ( ( ctauPV / ctauErrPV ) < sMin ) return false;
351  }
352  return true;
353  }
354 
355  private:
356  float pMin;
357  float cMin;
358  float sMin;
359 };
360 
361 
363 
364  useOnia = ( SET_LABEL( oniaCandsLabel, ps ) != "" );
365  useSd = ( SET_LABEL( sdCandsLabel, ps ) != "" );
366  useSs = ( SET_LABEL( ssCandsLabel, ps ) != "" );
367  useBu = ( SET_LABEL( buCandsLabel, ps ) != "" );
368  useBd = ( SET_LABEL( bdCandsLabel, ps ) != "" );
369  useBs = ( SET_LABEL( bsCandsLabel, ps ) != "" );
370  if ( useOnia ) consume< vector<pat::CompositeCandidate> >( oniaCandsToken,
371  oniaCandsLabel );
372  if ( useSd ) consume< vector<pat::CompositeCandidate> >( sdCandsToken,
373  sdCandsLabel );
374  if ( useSs ) consume< vector<pat::CompositeCandidate> >( ssCandsToken,
375  ssCandsLabel );
376  if ( useBu ) consume< vector<pat::CompositeCandidate> >( buCandsToken,
377  buCandsLabel );
378  if ( useBd ) consume< vector<pat::CompositeCandidate> >( bdCandsToken,
379  bdCandsLabel );
380  if ( useBs ) consume< vector<pat::CompositeCandidate> >( bsCandsToken,
381  bsCandsLabel );
382 
383  static const BPHSoftMuonSelect sms;
384 
385  double phiMassMin = 0.85;
386  double phiMassMax = 3.30;
387  double phiPtMin = 16.0;
388  double phiEtaMax = -1.0;
389  double phiRMax = -1.0;
390  double jPsiMassMin = 2.95;
391  double jPsiMassMax = 3.30;
392  double jPsiPtMin = 16.0;
393  double jPsiEtaMax = -1.0;
394  double jPsiRMax = -1.0;
395  double psi2MassMin = 3.40;
396  double psi2MassMax = 4.00;
397  double psi2PtMin = 13.0;
398  double psi2EtaMax = -1.0;
399  double psi2RMax = -1.0;
400  double upsMassMin = 8.50;
401  double upsMassMax = 11.0;
402  double upsPtMin = 13.0;
403  double upsEtaMax = -1.0;
404  double upsRMax = -1.0;
405 
406  double oniaProbMin = 0.005;
407  double oniaCosMin = -1.0;
408  double oniaSigMin = -1.0;
409 
410  double oniaMuPtMinLoose = -1.0;
411  double oniaMuPtMinTight = -1.0;
412  double oniaMuEtaMaxLoose = -1.0;
413  double oniaMuEtaMaxTight = -1.0;
414 
415  phiBasicSelect = new BPHCompositeBasicSelect(
416  phiMassMin, phiMassMax,
417  phiPtMin , phiEtaMax , phiRMax );
418  jPsiBasicSelect = new BPHCompositeBasicSelect(
419  jPsiMassMin, jPsiMassMax,
420  jPsiPtMin , jPsiEtaMax , jPsiRMax );
421  psi2BasicSelect = new BPHCompositeBasicSelect(
422  psi2MassMin, psi2MassMax,
423  psi2PtMin , psi2EtaMax , psi2RMax );
424  upsBasicSelect = new BPHCompositeBasicSelect(
425  upsMassMin, upsMassMax,
426  upsPtMin , upsEtaMax , upsRMax );
427  oniaVertexSelect = new BPHCompositeVertexSelect(
428  oniaProbMin, oniaCosMin, oniaSigMin );
429  oniaDaughterSelect = new BPHDaughterSelect(
430  oniaMuPtMinLoose , oniaMuPtMinTight ,
431  oniaMuEtaMaxLoose, oniaMuEtaMaxTight, &sms );
432 
433  double buJPsiMassMin = BPHParticleMasses::jPsiMass - 0.150;
434  double buJPsiMassMax = BPHParticleMasses::jPsiMass + 0.150;
435  double buJPsiPtMin = 8.0;
436  double buJPsiEtaMax = -1.0;
437  double buJPsiRMax = -1.0;
438  double buProbMin = 0.10;
439  double buCosMin = 0.99;
440  double buSigMin = 3.0;
441  double buMuPtMinLoose = 4.0;
442  double buMuPtMinTight = 4.0;
443  double buMuEtaMaxLoose = 2.2;
444  double buMuEtaMaxTight = 2.2;
445 
446  buKPtMin = 1.6;
447 
448  buJPsiBasicSelect = new BPHCompositeBasicSelect(
449  buJPsiMassMin, buJPsiMassMax,
450  buJPsiPtMin , buJPsiEtaMax , buJPsiRMax );
451  buVertexSelect = new BPHFittedVertexSelect(
452  buProbMin, buCosMin, buSigMin );
453  buJPsiDaughterSelect = new BPHDaughterSelect(
454  buMuPtMinLoose , buMuPtMinTight ,
455  buMuEtaMaxLoose, buMuEtaMaxTight, &sms );
456 
457  double bdJPsiMassMin = BPHParticleMasses::jPsiMass - 0.150;
458  double bdJPsiMassMax = BPHParticleMasses::jPsiMass + 0.150;
459  double bdJPsiPtMin = 8.0;
460  double bdJPsiEtaMax = -1.0;
461  double bdJPsiRMax = -1.0;
462  double bdKx0MassMin = BPHParticleMasses::kx0Mass - 0.075;
463  double bdKx0MassMax = BPHParticleMasses::kx0Mass + 0.075;
464  double bdKx0PtMin = -1.0;
465  double bdKx0EtaMax = -1.0;
466  double bdKx0RMax = -1.0;
467  double bdProbMin = 0.10;
468  double bdCosMin = 0.99;
469  double bdSigMin = 3.0;
470  double bdMuPtMinLoose = 4.0;
471  double bdMuPtMinTight = 4.0;
472  double bdMuEtaMaxLoose = 2.2;
473  double bdMuEtaMaxTight = 2.2;
474 
475  bdJPsiBasicSelect = new BPHCompositeBasicSelect(
476  bdJPsiMassMin, bdJPsiMassMax,
477  bdJPsiPtMin , bdJPsiEtaMax , bdJPsiRMax );
478  bdKx0BasicSelect = new BPHCompositeBasicSelect(
479  bdKx0MassMin, bdKx0MassMax,
480  bdKx0PtMin , bdKx0EtaMax , bdKx0RMax );
481  bdVertexSelect = new BPHFittedVertexSelect(
482  bdProbMin, bdCosMin, bdSigMin );
483  bdJPsiDaughterSelect = new BPHDaughterSelect(
484  bdMuPtMinLoose , bdMuPtMinTight ,
485  bdMuEtaMaxLoose, bdMuEtaMaxTight, &sms );
486 
487  double bsJPsiMassMin = BPHParticleMasses::jPsiMass - 0.150;
488  double bsJPsiMassMax = BPHParticleMasses::jPsiMass + 0.150;
489  double bsJPsiPtMin = 8.0;
490  double bsJPsiEtaMax = -1.0;
491  double bsJPsiRMax = -1.0;
492  double bsPhiMassMin = BPHParticleMasses::phiMass - 0.010;
493  double bsPhiMassMax = BPHParticleMasses::phiMass + 0.010;
494  double bsPhiPtMin = -1.0;
495  double bsPhiEtaMax = -1.0;
496  double bsPhiRMax = -1.0;
497  double bsProbMin = 0.10;
498  double bsCosMin = 0.99;
499  double bsSigMin = 3.0;
500  double bsMuPtMinLoose = 4.0;
501  double bsMuPtMinTight = 4.0;
502  double bsMuEtaMaxLoose = 2.2;
503  double bsMuEtaMaxTight = 2.2;
504  bsJPsiBasicSelect = new BPHCompositeBasicSelect(
505  bsJPsiMassMin, bsJPsiMassMax,
506  bsJPsiPtMin , bsJPsiEtaMax , bsJPsiRMax );
507  bsPhiBasicSelect = new BPHCompositeBasicSelect(
508  bsPhiMassMin, bsPhiMassMax,
509  bsPhiPtMin , bsPhiEtaMax , bsPhiRMax );
510  bsVertexSelect = new BPHFittedVertexSelect(
511  bsProbMin, bsCosMin, bsSigMin );
512  bsJPsiDaughterSelect = new BPHDaughterSelect(
513  bsMuPtMinLoose , bsMuPtMinTight ,
514  bsMuEtaMaxLoose, bsMuEtaMaxTight, &sms );
515 
516 }
517 
518 
520 
521  delete phiBasicSelect;
522  delete jPsiBasicSelect;
523  delete psi2BasicSelect;
524  delete upsBasicSelect;
525  delete oniaVertexSelect;
526  delete oniaDaughterSelect;
527 
528  delete buJPsiBasicSelect;
529  delete buVertexSelect;
530  delete buJPsiDaughterSelect;
531 
532  delete bdJPsiBasicSelect;
533  delete bdKx0BasicSelect;
534  delete bdVertexSelect;
535  delete bdJPsiDaughterSelect;
536 
537  delete bsJPsiBasicSelect;
538  delete bsPhiBasicSelect;
539  delete bsVertexSelect;
540  delete bsJPsiDaughterSelect;
541 
542 }
543 
544 
546  edm::ConfigurationDescriptions& descriptions ) {
548  desc.add<string>( "oniaCandsLabel", "" );
549  desc.add<string>( "sdCandsLabel", "" );
550  desc.add<string>( "ssCandsLabel", "" );
551  desc.add<string>( "buCandsLabel", "" );
552  desc.add<string>( "bdCandsLabel", "" );
553  desc.add<string>( "bsCandsLabel", "" );
554  descriptions.add( "bphHistoSpecificDecay", desc );
555  return;
556 }
557 
558 
560  createHisto( "massPhi" , 35, 0.85, 1.20 ); // Phi mass
561  createHisto( "massJPsi" , 35, 2.95, 3.30 ); // JPsi mass
562  createHisto( "massPsi2" , 60, 3.40, 4.00 ); // Psi2 mass
563  createHisto( "massUps123" , 125, 8.50, 11.0 ); // Ups mass
564  createHisto( "massBu" , 50, 5.00, 6.00 ); // Bu mass
565  createHisto( "massBd" , 50, 5.00, 6.00 ); // Bd mass
566  createHisto( "massBs" , 50, 5.00, 6.00 ); // Bs mass
567  createHisto( "mfitBu" , 50, 5.00, 6.00 ); // Bu mass, with constraint
568  createHisto( "mfitBd" , 50, 5.00, 6.00 ); // Bd mass, with constraint
569  createHisto( "mfitBs" , 50, 5.00, 6.00 ); // Bs mass, with constraint
570  createHisto( "massBuJPsi" , 35, 2.95, 3.30 ); // JPsi mass in Bu decay
571  createHisto( "massBdJPsi" , 35, 2.95, 3.30 ); // JPsi mass in Bd decay
572  createHisto( "massBsJPsi" , 35, 2.95, 3.30 ); // JPsi mass in Bs decay
573  createHisto( "massBsPhi" , 50, 1.01, 1.03 ); // Phi mass in Bs decay
574  createHisto( "massBdKx0" , 50, 0.80, 1.05 ); // Kx0 mass in Bd decay
575 
576  createHisto( "massFull" , 200, 2.00, 12.0 ); // Full onia mass
577 
578  return;
579 }
580 
582  const edm::EventSetup& es ) {
583 
584  // get magnetic field
586  es.get<IdealMagneticFieldRecord>().get( magneticField );
587 
588  // get object collections
589  // collections are got through "BPHTokenWrapper" interface to allow
590  // uniform access in different CMSSW versions
591 
593 
595  int iqo;
596  int nqo = 0;
597  if ( useOnia ) {
598  oniaCandsToken.get( ev, oniaCands );
599  nqo = oniaCands->size();
600  }
601 
602  for ( iqo = 0; iqo < nqo; ++ iqo ) {
603  LogTrace( "DataDump" )
604  << "*********** quarkonium " << iqo << "/" << nqo << " ***********";
605  const pat::CompositeCandidate& cand = oniaCands->at( iqo );
606  if ( !oniaVertexSelect->accept( cand,
607  BPHUserData::getByRef<reco::Vertex>( cand,
608  "primaryVertex" ) ) ) continue;
609  if ( !oniaDaughterSelect->accept( cand ) ) continue;
610  fillHisto( "Full", cand );
611  if ( phiBasicSelect->accept( cand ) ) fillHisto( "Phi" , cand );
612  if ( jPsiBasicSelect->accept( cand ) ) fillHisto( "JPsi" , cand );
613  if ( psi2BasicSelect->accept( cand ) ) fillHisto( "Psi2" , cand );
614  if ( upsBasicSelect->accept( cand ) ) fillHisto( "Ups123", cand );
615  }
616 
618 
620  int ibu;
621  int nbu = 0;
622  if ( useBu ) {
623  buCandsToken.get( ev, buCands );
624  nbu = buCands->size();
625  }
626 
627  for ( ibu = 0; ibu < nbu; ++ ibu ) {
628  LogTrace( "DataDump" )
629  << "*********** Bu " << ibu << "/" << nbu << " ***********";
630  const pat::CompositeCandidate& cand = buCands->at( ibu );
632  <pat::CompositeCandidate>( cand, "refToJPsi" );
633  LogTrace( "DataDump" )
634  << "JPsi: " << jPsi;
635  if ( jPsi == nullptr ) continue;
636  if ( !buJPsiBasicSelect ->accept( *jPsi ) ) continue;
637  if ( !buJPsiDaughterSelect->accept( *jPsi ) ) continue;
638  if ( !buVertexSelect->accept( cand,
639  BPHUserData::getByRef<reco::Vertex>( *jPsi,
640  "primaryVertex" ) ) ) continue;
641  const reco::Candidate* kptr = BPHDaughters::get( cand, 0.49, 0.50 ).front();
642  if ( kptr == nullptr ) continue;
643  if ( kptr->pt() < buKPtMin ) continue;
644  fillHisto( "Bu" , cand );
645  fillHisto( "BuJPsi", *jPsi );
646  }
647 
649 
651  int ibd;
652  int nbd = 0;
653  if ( useBd ) {
654  bdCandsToken.get( ev, bdCands );
655  nbd = bdCands->size();
656  }
657 
658  for ( ibd = 0; ibd < nbd; ++ ibd ) {
659  LogTrace( "DataDump" )
660  << "*********** Bd " << ibd << "/" << nbd << " ***********";
661  const pat::CompositeCandidate& cand = bdCands->at( ibd );
663  <pat::CompositeCandidate>( cand, "refToJPsi" );
664  LogTrace( "DataDump" )
665  << "JPsi: " << jPsi;
666  if ( jPsi == nullptr ) continue;
668  <pat::CompositeCandidate>( cand, "refToKx0" );
669  LogTrace( "DataDump" )
670  << "Kx0: " << kx0;
671  if ( kx0 == nullptr ) continue;
672  if ( !bdJPsiBasicSelect ->accept( *jPsi ) ) continue;
673  if ( !bdKx0BasicSelect ->accept( * kx0 ) ) continue;
674  if ( !bdJPsiDaughterSelect->accept( *jPsi ) ) continue;
675  if ( !bdVertexSelect->accept( cand,
676  BPHUserData::getByRef<reco::Vertex>( *jPsi,
677  "primaryVertex" ) ) ) continue;
678  fillHisto( "Bd" , cand );
679  fillHisto( "BdJPsi", *jPsi );
680  fillHisto( "BdKx0" , *kx0 );
681  }
682 
684 
686  int ibs;
687  int nbs = 0;
688  if ( useBs ) {
689  bsCandsToken.get( ev, bsCands );
690  nbs = bsCands->size();
691  }
692 
693  for ( ibs = 0; ibs < nbs; ++ ibs ) {
694  LogTrace( "DataDump" )
695  << "*********** Bs " << ibs << "/" << nbs << " ***********";
696  const pat::CompositeCandidate& cand = bsCands->at( ibs );
698  <pat::CompositeCandidate>( cand, "refToJPsi" );
699  LogTrace( "DataDump" )
700  << "JPsi: " << jPsi;
701  if ( jPsi == nullptr ) continue;
703  <pat::CompositeCandidate>( cand, "refToPhi" );
704  LogTrace( "DataDump" )
705  << "Phi: " << phi;
706  if ( phi == nullptr ) continue;
707  if ( !bsJPsiBasicSelect ->accept( *jPsi ) ) continue;
708  if ( !bsPhiBasicSelect ->accept( * phi ) ) continue;
709  if ( !bsJPsiDaughterSelect->accept( *jPsi ) ) continue;
710  if ( !bsVertexSelect->accept( cand,
711  BPHUserData::getByRef<reco::Vertex>( *jPsi,
712  "primaryVertex" ) ) ) continue;
713  fillHisto( "Bs" , cand );
714  fillHisto( "BsJPsi", *jPsi );
715  fillHisto( "BsPhi" , *phi );
716  }
717 
718 
719  return;
720 
721 }
722 
723 
725  return;
726 }
727 
728 
729 void BPHHistoSpecificDecay::fillHisto( const string& name,
730  const pat::CompositeCandidate& cand ) {
731  float mass = ( cand.hasUserFloat( "fitMass" ) ?
732  cand. userFloat( "fitMass" ) : -1 );
733  fillHisto( "mass" + name, cand.mass() );
734  fillHisto( "mfit" + name, mass );
735  return;
736 }
737 
738 
739 void BPHHistoSpecificDecay::fillHisto( const string& name, float x ) {
740  map<string,TH1F*>::iterator iter = histoMap.find( name );
741  map<string,TH1F*>::iterator iend = histoMap.end();
742  if ( iter == iend ) return;
743  iter->second->Fill( x );
744  return;
745 }
746 
747 
749  int nbin, float hmin, float hmax ) {
750  histoMap[name] = fs->make<TH1F>( name.c_str(), name.c_str(),
751  nbin, hmin, hmax );
752  return;
753 }
754 
756 
Analysis-level particle class.
BPHDaughterSelect(float ptMinLoose, float ptMinTight, float etaMaxLoose, float etaMaxTight, const BPHSoftMuonSelect *softMuonselector=0)
const reco::Vertex * pv
BPHHistoSpecificDecay(const edm::ParameterSet &ps)
BPHCompositeBasicSelect(float massMin, float massMax, float ptMin=-1.0, float etaMax=-1.0, float rapidityMax=-1.0)
BPHFittedVertexSelect(float probMin, float cosMin=-1.0, float sigMin=-1.0)
static const T * getByRef(const pat::CompositeCandidate &cand, const string &name)
bool accept(const pat::CompositeCandidate &cand, const reco::Vertex *pv=0) const override
const AlgebraicSymMatrix33 matrix() const
double y() const
y coordinate
Definition: Vertex.h:113
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
double rapidity() const final
rapidity
bool hasUserFloat(const std::string &key) const
Return true if there is a user-defined float with a given name.
Definition: PATObject.h:334
bool ev
bool accept(const pat::CompositeCandidate &cand, const reco::Vertex *pvtx=0) const override
static const double jPsiMass
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
const Point & position() const
position
Definition: Vertex.h:109
float userFloat(const std::string &key) const
Definition: PATObject.h:791
static const T * get(const pat::CompositeCandidate &cand, const string &name)
bool accept(const pat::CompositeCandidate &cand, const reco::Vertex *pv=0) const override
void analyze(const edm::Event &ev, const edm::EventSetup &es) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static const double kx0Mass
reco::TrackRef innerTrack() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:72
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
T sqrt(T t)
Definition: SSEVec.h:18
void createHisto(const std::string &name, int nbin, float hmin, float hmax)
ROOT::Math::SVector< double, 3 > AlgebraicVector3
def pv(vc)
Definition: MetAnalyzer.py:7
double chi2() const
chi-squares
Definition: Vertex.h:98
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
float ChiSquaredProbability(double chiSquared, double nrDOF)
BPHFittedBasicSelect(float massMin, float massMax, float ptMin=-1.0, float etaMax=-1.0, float rapidityMax=-1.0)
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
const T * userData(const std::string &key) const
Returns user-defined data. Returns NULL if the data is not present, or not of type T...
Definition: PATObject.h:280
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool hasUserData(const std::string &key) const
Check if user data with a specific type is present.
Definition: PATObject.h:286
#define LogTrace(id)
double ndof() const
Definition: Vertex.h:105
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
bool accept(const reco::Candidate &cand, const reco::Vertex *pv) const
static const double phiMass
bool accept(const pat::CompositeCandidate &cand, const reco::Vertex *pvtx) const override
double x() const
x coordinate
Definition: Vertex.h:111
bool accept(const pat::CompositeCandidate &cand, const reco::Vertex *pv=0) const override
BPHCompositeVertexSelect(float probMin, float cosMin=-1.0, float sigMin=-1.0)
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
virtual double mass() const =0
mass
void add(std::string const &label, ParameterSetDescription const &psetDescription)
double value() const
Definition: Measurement1D.h:25
Error error() const
return SMatrix
Definition: Vertex.h:139
T get() const
Definition: EventSetup.h:71
BPHSoftMuonSelect(int cutTrackerLayers=5, int cutPixelLayers=0, float maxDxy=0.3, float maxDz=20.0, bool goodMuon=true, bool highPurity=true)
static vector< const reco::Candidate * > get(const pat::CompositeCandidate &cand, float massMin, float massMax)
long double T
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const BPHSoftMuonSelect * sms
Analysis-level muon class.
Definition: Muon.h:51
#define SET_LABEL(NAME, PSET)
double mass() const final
mass
void fillHisto(const std::string &name, const pat::CompositeCandidate &cand)