CMS 3D CMS Logo

BPHWriteSpecificDecay.cc
Go to the documentation of this file.
2 
4 
12 
20 
27 
30 
33 
36 
39 
40 #include <set>
41 #include <string>
42 #include <iostream>
43 #include <fstream>
44 
45 using namespace std;
46 
47 #define SET_PAR(TYPE,NAME,PSET) ( NAME = PSET.getParameter< TYPE >( #NAME ) )
48 // SET_PAR(string,xyz,ps);
49 // is equivalent to
50 // ( xyz = ps.getParameter< string >( "xyx" ) )
51 
53 
54  usePV = ( SET_PAR( string, pVertexLabel, ps ) != "" );
55  usePM = ( SET_PAR( string, patMuonLabel, ps ) != "" );
56  useCC = ( SET_PAR( string, ccCandsLabel, ps ) != "" );
57  usePF = ( SET_PAR( string, pfCandsLabel, ps ) != "" );
58  usePC = ( SET_PAR( string, pcCandsLabel, ps ) != "" );
59  useGP = ( SET_PAR( string, gpCandsLabel, ps ) != "" );
60  SET_PAR( string, oniaName, ps );
61  SET_PAR( string, sdName, ps );
62  SET_PAR( string, ssName, ps );
63  SET_PAR( string, buName, ps );
64  SET_PAR( string, bdName, ps );
65  SET_PAR( string, bsName, ps );
66 
67  SET_PAR( bool, writeMomentum, ps );
68  SET_PAR( bool, writeVertex , ps );
69 
70  rMap["Onia" ] = Onia;
71  rMap["PHiMuMu"] = Pmm;
72  rMap["Psi1" ] = Psi1;
73  rMap["Psi2" ] = Psi2;
74  rMap["Ups" ] = Ups;
75  rMap["Ups1" ] = Ups1;
76  rMap["Ups2" ] = Ups2;
77  rMap["Ups3" ] = Ups3;
78  rMap["Kx0" ] = Kx0;
79  rMap["PhiKK" ] = Pkk;
80  rMap["Bu" ] = Bu;
81  rMap["Bd" ] = Bd;
82  rMap["Bs" ] = Bs;
83 
84  pMap["ptMin" ] = ptMin;
85  pMap["etaMax" ] = etaMax;
86  pMap["mJPsiMin" ] = mPsiMin;
87  pMap["mJPsiMax" ] = mPsiMax;
88  pMap["mKx0Min" ] = mKx0Min;
89  pMap["mKx0Max" ] = mKx0Max;
90  pMap["mPhiMin" ] = mPhiMin;
91  pMap["mPhiMax" ] = mPhiMax;
92  pMap["massMin" ] = massMin;
93  pMap["massMax" ] = massMax;
94  pMap["probMin" ] = probMin;
95  pMap["massFitMin" ] = mFitMin;
96  pMap["massFitMax" ] = mFitMax;
97  pMap["constrMass" ] = constrMass;
98  pMap["constrSigma"] = constrSigma;
99 
100  fMap["constrMJPsi" ] = constrMJPsi;
101  fMap["writeCandidate"] = writeCandidate;
102 
103  recoOnia =
104  recoKx0 = writeKx0 =
105  recoPkk = writePkk =
106  recoBu = writeBu =
107  recoBd = writeBd =
108  recoBs = writeBs = false;
109 
110  writeOnia = true;
111  const vector<edm::ParameterSet> recoSelect =
112  ps.getParameter< vector<edm::ParameterSet> >( "recoSelect" );
113  int iSel;
114  int nSel = recoSelect.size();
115  for ( iSel = 0; iSel < nSel; ++iSel ) setRecoParameters( recoSelect[iSel] );
116  if ( !recoOnia ) writeOnia = false;
117 
118  if ( recoBu ) recoOnia = true;
119  if ( recoBd ) recoOnia = recoKx0 = true;
120  if ( recoBs ) recoOnia = recoPkk = true;
121  if ( writeBu ) writeOnia = true;
122  if ( writeBd ) writeOnia = writeKx0 = true;
123  if ( writeBs ) writeOnia = writePkk = true;
124 
125  if ( usePV ) consume< vector<reco::Vertex > >( pVertexToken,
126  pVertexLabel );
127  if ( usePM ) consume< pat::MuonCollection >( patMuonToken,
128  patMuonLabel );
129  if ( useCC ) consume< vector<pat::CompositeCandidate > >( ccCandsToken,
130  ccCandsLabel );
131  if ( usePF ) consume< vector<reco::PFCandidate > >( pfCandsToken,
132  pfCandsLabel );
133  if ( usePC ) consume< vector<BPHTrackReference::candidate> >( pcCandsToken,
134  pcCandsLabel );
135  if ( useGP ) consume< vector<pat::GenericParticle > >( gpCandsToken,
136  gpCandsLabel );
137 
138  if ( writeOnia ) produces<pat::CompositeCandidateCollection>( oniaName );
139  if ( writeKx0 ) produces<pat::CompositeCandidateCollection>( sdName );
140  if ( writePkk ) produces<pat::CompositeCandidateCollection>( ssName );
141  if ( writeBu ) produces<pat::CompositeCandidateCollection>( buName );
142  if ( writeBd ) produces<pat::CompositeCandidateCollection>( bdName );
143  if ( writeBs ) produces<pat::CompositeCandidateCollection>( bsName );
144 
145 }
146 
147 
149 }
150 
151 
153  edm::ConfigurationDescriptions& descriptions ) {
155  desc.add<string>( "pVertexLabel", "" );
156  desc.add<string>( "patMuonLabel", "" );
157  desc.add<string>( "ccCandsLabel", "" );
158  desc.add<string>( "pfCandsLabel", "" );
159  desc.add<string>( "pcCandsLabel", "" );
160  desc.add<string>( "gpCandsLabel", "" );
161  desc.add<string>( "oniaName", "oniaCand" );
162  desc.add<string>( "sdName", "kx0Cand" );
163  desc.add<string>( "ssName", "phiCand" );
164  desc.add<string>( "buName", "buFitted" );
165  desc.add<string>( "bdName", "bdFitted" );
166  desc.add<string>( "bsName", "bsFitted" );
167  desc.add<bool>( "writeVertex" , true );
168  desc.add<bool>( "writeMomentum", true );
170  dpar.add<string>( "name" );
171  dpar.add<double>( "ptMin", -2.0e35 );
172  dpar.add<double>( "etaMax", -2.0e35 );
173  dpar.add<double>( "mJPsiMin", -2.0e35 );
174  dpar.add<double>( "mJPsiMax", -2.0e35 );
175  dpar.add<double>( "mKx0Min", -2.0e35 );
176  dpar.add<double>( "mKx0Max", -2.0e35 );
177  dpar.add<double>( "mPhiMin", -2.0e35 );
178  dpar.add<double>( "mPhiMax", -2.0e35 );
179  dpar.add<double>( "massMin", -2.0e35 );
180  dpar.add<double>( "massMax", -2.0e35 );
181  dpar.add<double>( "probMin", -2.0e35 );
182  dpar.add<double>( "massFitMin", -2.0e35 );
183  dpar.add<double>( "massFitMax", -2.0e35 );
184  dpar.add<double>( "constrMass", -2.0e35 );
185  dpar.add<double>( "constrSigma", -2.0e35 );
186  dpar.add<bool>( "constrMJPsi", true );
187  dpar.add<bool>( "writeCandidate", true );
188  vector<edm::ParameterSet> rpar;
189  desc.addVPSet( "recoSelect", dpar, rpar );
190  descriptions.add( "bphWriteSpecificDecay", desc );
191  return;
192 }
193 
194 
196  return;
197 }
198 
199 
201  const edm::EventSetup& es ) {
202  fill( ev, es );
203  if ( writeOnia ) write( ev, lFull, oniaName );
204  if ( writeKx0 ) write( ev, lSd , sdName );
205  if ( writePkk ) write( ev, lSs , ssName );
206  if ( writeBu ) write( ev, lBu , buName );
207  if ( writeBd ) write( ev, lBd , bdName );
208  if ( writeBs ) write( ev, lBs , bsName );
209  return;
210 }
211 
212 
214  const edm::EventSetup& es ) {
215 
216  lFull.clear();
217  lJPsi.clear();
218  lSd.clear();
219  lSs.clear();
220  lBu.clear();
221  lBd.clear();
222  lBs.clear();
223  jPsiOMap.clear();
224  pvRefMap.clear();
225  ccRefMap.clear();
226 
227  // get magnetic field
229  es.get<IdealMagneticFieldRecord>().get( magneticField );
230 
231  // get object collections
232  // collections are got through "BPHTokenWrapper" interface to allow
233  // uniform access in different CMSSW versions
234 
236  pVertexToken.get( ev, pVertices );
237  int npv = pVertices->size();
238 
239  int nrc = 0;
240 
241  // get reco::PFCandidate collection (in full AOD )
243  if ( usePF ) {
244  pfCandsToken.get( ev, pfCands );
245  nrc = pfCands->size();
246  }
247 
248  // get pat::PackedCandidate collection (in MiniAOD)
249  // pat::PackedCandidate is not defined in CMSSW_5XY, so a
250  // typedef (BPHTrackReference::candidate) is used, actually referring
251  // to pat::PackedCandidate only for CMSSW versions where it's defined
253  if ( usePC ) {
254  pcCandsToken.get( ev, pcCands );
255  nrc = pcCands->size();
256  }
257 
258  // get pat::GenericParticle collection (in skimmed data)
260  if ( useGP ) {
261  gpCandsToken.get( ev, gpCands );
262  nrc = gpCands->size();
263  }
264 
265  // get pat::Muon collection (in full AOD and MiniAOD)
267  if ( usePM ) {
268  patMuonToken.get( ev, patMuon );
269  }
270 
271  // get muons from pat::CompositeCandidate objects describing onia;
272  // muons from all composite objects are copied to an unique std::vector
273  vector<const reco::Candidate*> muDaugs;
274  set<const pat::Muon*> muonSet;
275  typedef multimap<const reco::Candidate*,
276  const pat::CompositeCandidate*> mu_cc_map;
277  mu_cc_map muCCMap;
278  if ( useCC ) {
280  ccCandsToken.get( ev, ccCands );
281  int n = ccCands->size();
282  muDaugs.clear();
283  muDaugs.reserve( n );
284  muonSet.clear();
285  set<const pat::Muon*>::const_iterator iter;
286  set<const pat::Muon*>::const_iterator iend;
287  int i;
288  for ( i = 0; i < n; ++i ) {
289  const pat::CompositeCandidate& cc = ccCands->at( i );
290  int j;
291  int m = cc.numberOfDaughters();
292  for ( j = 0; j < m; ++j ) {
293  const reco::Candidate* dp = cc.daughter( j );
294  const pat::Muon* mp = dynamic_cast<const pat::Muon*>( dp );
295  iter = muonSet.begin();
296  iend = muonSet.end();
297  bool add = ( mp != 0 ) && ( muonSet.find( mp ) == iend );
298  while ( add && ( iter != iend ) ) {
299  if ( BPHRecoBuilder::sameTrack( mp, *iter++, 1.0e-5 ) ) add = false;
300  }
301  if ( add ) muonSet.insert( mp );
302  // associate muon to the CompositeCandidate containing it
303  muCCMap.insert( pair<const reco::Candidate*,
304  const pat::CompositeCandidate*>( dp, &cc ) );
305  }
306  }
307  iter = muonSet.begin();
308  iend = muonSet.end();
309  while ( iter != iend ) muDaugs.push_back( *iter++ );
310  }
311 
312  map< recoType, map<parType,double> >::const_iterator rIter = parMap.begin();
313  map< recoType, map<parType,double> >::const_iterator rIend = parMap.end();
314 
315  // reconstruct quarkonia
316 
317  BPHOniaToMuMuBuilder* onia = 0;
318  if ( recoOnia ) {
319  if ( usePM ) onia = new BPHOniaToMuMuBuilder( es,
320  BPHRecoBuilder::createCollection( patMuon, "cfmig" ),
321  BPHRecoBuilder::createCollection( patMuon, "cfmig" ) );
322  else
323  if ( useCC ) onia = new BPHOniaToMuMuBuilder( es,
324  BPHRecoBuilder::createCollection( muDaugs, "cfmig" ),
325  BPHRecoBuilder::createCollection( muDaugs, "cfmig" ) );
326  }
327 
328  if ( onia != 0 ) {
329  while ( rIter != rIend ) {
330  const map< recoType, map<parType,double> >::value_type& rEntry = *rIter++;
331  recoType rType = rEntry.first;
332  const map<parType,double>& pMap = rEntry.second;
334  switch( rType ) {
335  case Pmm : type = BPHOniaToMuMuBuilder::Phi ; break;
336  case Psi1: type = BPHOniaToMuMuBuilder::Psi1; break;
337  case Psi2: type = BPHOniaToMuMuBuilder::Psi2; break;
338  case Ups : type = BPHOniaToMuMuBuilder::Ups ; break;
339  case Ups1: type = BPHOniaToMuMuBuilder::Ups1; break;
340  case Ups2: type = BPHOniaToMuMuBuilder::Ups2; break;
341  case Ups3: type = BPHOniaToMuMuBuilder::Ups3; break;
342  default: continue;
343  }
344  map<parType,double>::const_iterator pIter = pMap.begin();
345  map<parType,double>::const_iterator pIend = pMap.end();
346  while ( pIter != pIend ) {
347  const map<parType,double>::value_type& pEntry = *pIter++;
348  parType id = pEntry.first;
349  double pv = pEntry.second;
350  switch( id ) {
351  case ptMin : onia->setPtMin ( type, pv ); break;
352  case etaMax : onia->setEtaMax ( type, pv ); break;
353  case massMin : onia->setMassMin( type, pv ); break;
354  case massMax : onia->setMassMax( type, pv ); break;
355  case probMin : onia->setProbMin( type, pv ); break;
356  case constrMass : onia->setConstr ( type, pv,
357  onia->getConstrSigma( type )
358  ); break;
359  case constrSigma: onia->setConstr ( type, onia->getConstrMass ( type ),
360  pv ); break;
361  default: break;
362  }
363  }
364  }
365  lFull = onia->build();
366  }
367 
368  // associate onia to primary vertex
369 
370  int iFull;
371  int nFull = lFull.size();
372  map<const BPHRecoCandidate*,const reco::Vertex*> oniaVtxMap;
373 
374  typedef mu_cc_map::const_iterator mu_cc_iter;
375  for ( iFull = 0; iFull < nFull; ++iFull ) {
376 
377  const reco::Vertex* pVtx = 0;
378  int pvId = 0;
379  const BPHPlusMinusCandidate* ptr = lFull[iFull].get();
380  const std::vector<const reco::Candidate*>& daugs = ptr->daughters();
381 
382  // try to recover primary vertex association in skim data:
383  // get the CompositeCandidate containing both muons
384  pair<mu_cc_iter,mu_cc_iter> cc0 = muCCMap.equal_range(
385  ptr->originalReco( daugs[0] ) );
386  pair<mu_cc_iter,mu_cc_iter> cc1 = muCCMap.equal_range(
387  ptr->originalReco( daugs[1] ) );
388  mu_cc_iter iter0 = cc0.first;
389  mu_cc_iter iend0 = cc0.second;
390  mu_cc_iter iter1 = cc1.first;
391  mu_cc_iter iend1 = cc1.second;
392  while ( ( iter0 != iend0 ) && ( pVtx == 0 ) ) {
393  const pat::CompositeCandidate* ccp = iter0++->second;
394  while ( iter1 != iend1 ) {
395  if ( ccp != iter1++->second ) continue;
396  pVtx = ccp->userData<reco::Vertex>( "PVwithmuons" );
397  const reco::Vertex* sVtx = 0;
398  const reco::Vertex::Point& pPos = pVtx->position();
399  float dMin = 999999.;
400  int ipv;
401  for ( ipv = 0; ipv < npv; ++ipv ) {
402  const reco::Vertex* tVtx = &pVertices->at( ipv );
403  const reco::Vertex::Point& tPos = tVtx->position();
404  float dist = pow( pPos.x() - tPos.x(), 2 ) +
405  pow( pPos.y() - tPos.y(), 2 ) +
406  pow( pPos.z() - tPos.z(), 2 );
407  if ( dist < dMin ) {
408  dMin = dist;
409  sVtx = tVtx;
410  pvId = ipv;
411  }
412  }
413  pVtx = sVtx;
414  break;
415  }
416  }
417 
418  // if not found, as ofr other type of inut data,
419  // try to get the nearest primary vertex in z direction
420  if ( pVtx == 0 ) {
421  const reco::Vertex::Point& sVtp = ptr->vertex().position();
422  GlobalPoint cPos( sVtp.x(), sVtp.y(), sVtp.z() );
423  const pat::CompositeCandidate& sCC = ptr->composite();
424  GlobalVector cDir( sCC.px(), sCC.py(), sCC.pz() );
425  GlobalPoint bPos( 0.0, 0.0, 0.0 );
426  GlobalVector bDir( 0.0, 0.0, 1.0 );
428  bool state = ttmd.calculate( GlobalTrajectoryParameters( cPos, cDir,
429  TrackCharge( 0 ), &( *magneticField ) ),
430  GlobalTrajectoryParameters( bPos, bDir,
431  TrackCharge( 0 ), &( *magneticField ) ) );
432  float minDz = 999999.;
433  float extrapZ = ( state ? ttmd.points().first.z() : -9e20 );
434  int ipv;
435  for ( ipv = 0; ipv < npv; ++ipv ) {
436  const reco::Vertex& tVtx = pVertices->at( ipv );
437  float deltaZ = fabs( extrapZ - tVtx.position().z() ) ;
438  if ( deltaZ < minDz ) {
439  minDz = deltaZ;
440  pVtx = &tVtx;
441  pvId = ipv;
442  }
443  }
444  }
445 
446  oniaVtxMap[ptr] = pVtx;
447  pvRefMap[ptr] = vertex_ref( pVertices, pvId );
448 
449  }
450  pVertexToken.get( ev, pVertices );
451 
452  // get JPsi subsample and associate JPsi candidate to original
453  // generic onia candidate
454  if ( nFull ) lJPsi = onia->getList( BPHOniaToMuMuBuilder::Psi1 );
455 
456  int nJPsi = lJPsi.size();
457  delete onia;
458 
459  if ( !nJPsi ) return;
460  if ( !nrc ) return;
461 
462  int ij;
463  int io;
464  int nj = lJPsi.size();
465  int no = lFull.size();
466  for ( ij = 0; ij < nj; ++ij ) {
467  const BPHRecoCandidate* jp = lJPsi[ij].get();
468  for ( io = 0; io < no; ++io ) {
469  const BPHRecoCandidate* oc = lFull[io].get();
470  if ( ( jp->originalReco( jp->getDaug( "MuPos" ) ) ==
471  oc->originalReco( oc->getDaug( "MuPos" ) ) ) &&
472  ( jp->originalReco( jp->getDaug( "MuNeg" ) ) ==
473  oc->originalReco( oc->getDaug( "MuNeg" ) ) ) ) {
474  jPsiOMap[jp] = oc;
475  break;
476  }
477  }
478  }
479 
480  // build and dump Bu
481 
482  BPHBuToJPsiKBuilder* bu = 0;
483  if ( recoBu ) {
484  if ( usePF ) bu = new BPHBuToJPsiKBuilder( es, lJPsi,
486  else
487  if ( usePC ) bu = new BPHBuToJPsiKBuilder( es, lJPsi,
489  else
490  if ( useGP ) bu = new BPHBuToJPsiKBuilder( es, lJPsi,
492  }
493 
494  if ( bu != 0 ) {
495  rIter = parMap.find( Bu );
496  if ( rIter != rIend ) {
497  const map<parType,double>& pMap = rIter->second;
498  map<parType,double>::const_iterator pIter = pMap.begin();
499  map<parType,double>::const_iterator pIend = pMap.end();
500  while ( pIter != pIend ) {
501  const map<parType,double>::value_type& pEntry = *pIter++;
502  parType id = pEntry.first;
503  double pv = pEntry.second;
504  switch( id ) {
505  case ptMin : bu->setKPtMin ( pv ); break;
506  case etaMax : bu->setKEtaMax ( pv ); break;
507  case mPsiMin : bu->setJPsiMassMin( pv ); break;
508  case mPsiMax : bu->setJPsiMassMax( pv ); break;
509  case massMin : bu->setMassMin ( pv ); break;
510  case massMax : bu->setMassMax ( pv ); break;
511  case probMin : bu->setProbMin ( pv ); break;
512  case mFitMin : bu->setMassFitMin ( pv ); break;
513  case mFitMax : bu->setMassFitMax ( pv ); break;
514  case constrMJPsi: bu->setConstr ( pv > 0 ); break;
515  case writeCandidate: writeBu = ( pv > 0 ); break;
516  default: break;
517  }
518  }
519  }
520  lBu = bu->build();
521  delete bu;
522  }
523 
524  // build and dump Kx0
525 
526  vector<BPHPlusMinusConstCandPtr> lKx0;
527  BPHKx0ToKPiBuilder* kx0 = 0;
528  if ( recoKx0 ) {
529  if ( usePF ) kx0 = new BPHKx0ToKPiBuilder( es,
532  else
533  if ( usePC ) kx0 = new BPHKx0ToKPiBuilder( es,
536  else
537  if ( useGP ) kx0 = new BPHKx0ToKPiBuilder( es,
540  }
541 
542  if ( kx0 != 0 ) {
543  rIter = parMap.find( Kx0 );
544  if ( rIter != rIend ) {
545  const map<parType,double>& pMap = rIter->second;
546  map<parType,double>::const_iterator pIter = pMap.begin();
547  map<parType,double>::const_iterator pIend = pMap.end();
548  while ( pIter != pIend ) {
549  const map<parType,double>::value_type& pEntry = *pIter++;
550  parType id = pEntry.first;
551  double pv = pEntry.second;
552  switch( id ) {
553  case ptMin : kx0->setPtMin ( pv ); break;
554  case etaMax : kx0->setEtaMax ( pv ); break;
555  case massMin : kx0->setMassMin( pv ); break;
556  case massMax : kx0->setMassMax( pv ); break;
557  case probMin : kx0->setProbMin( pv ); break;
558  case constrMass : kx0->setConstr ( pv, kx0->getConstrSigma() ); break;
559  case constrSigma: kx0->setConstr ( kx0->getConstrMass() , pv ); break;
560  case writeCandidate: writeKx0 = ( pv > 0 ); break;
561  default: break;
562  }
563  }
564  }
565  lKx0 = kx0->build();
566  delete kx0;
567  }
568 
569  int nKx0 = lKx0.size();
570 
571  // build and dump Bd
572 
573  if ( recoBd && nKx0 ) {
574 
575  BPHBdToJPsiKxBuilder* bd = new BPHBdToJPsiKxBuilder( es, lJPsi, lKx0 );
576  rIter = parMap.find( Bd );
577  if ( rIter != rIend ) {
578  const map<parType,double>& pMap = rIter->second;
579  map<parType,double>::const_iterator pIter = pMap.begin();
580  map<parType,double>::const_iterator pIend = pMap.end();
581  while ( pIter != pIend ) {
582  const map<parType,double>::value_type& pEntry = *pIter++;
583  parType id = pEntry.first;
584  double pv = pEntry.second;
585  switch( id ) {
586  case mPsiMin : bd->setJPsiMassMin( pv ); break;
587  case mPsiMax : bd->setJPsiMassMax( pv ); break;
588  case mKx0Min : bd->setKxMassMin ( pv ); break;
589  case mKx0Max : bd->setKxMassMax ( pv ); break;
590  case massMin : bd->setMassMin ( pv ); break;
591  case massMax : bd->setMassMax ( pv ); break;
592  case probMin : bd->setProbMin ( pv ); break;
593  case mFitMin : bd->setMassFitMin ( pv ); break;
594  case mFitMax : bd->setMassFitMax ( pv ); break;
595  case constrMJPsi: bd->setConstr ( pv > 0 ); break;
596  case writeCandidate: writeBd = ( pv > 0 ); break;
597  default: break;
598  }
599  }
600  }
601 
602  lBd = bd->build();
603  delete bd;
604 
605  set<BPHRecoConstCandPtr> sKx0;
606  int iBd;
607  int nBd = lBd.size();
608  for ( iBd = 0; iBd < nBd; ++iBd ) sKx0.insert( lBd[iBd]->getComp( "Kx0" ) );
609  set<BPHRecoConstCandPtr>::const_iterator iter = sKx0.begin();
610  set<BPHRecoConstCandPtr>::const_iterator iend = sKx0.end();
611  while ( iter != iend ) lSd.push_back( *iter++ );
612 
613  }
614 
615  // build and dump Phi
616 
617  vector<BPHPlusMinusConstCandPtr> lPhi;
618  BPHPhiToKKBuilder* phi = 0;
619  if ( recoPkk ) {
620  if ( usePF ) phi = new BPHPhiToKKBuilder( es,
623  else
624  if ( usePC ) phi = new BPHPhiToKKBuilder( es,
627  else
628  if ( useGP ) phi = new BPHPhiToKKBuilder( es,
631  }
632 
633  if ( phi != 0 ) {
634  rIter = parMap.find( Pkk );
635  if ( rIter != rIend ) {
636  const map<parType,double>& pMap = rIter->second;
637  map<parType,double>::const_iterator pIter = pMap.begin();
638  map<parType,double>::const_iterator pIend = pMap.end();
639  while ( pIter != pIend ) {
640  const map<parType,double>::value_type& pEntry = *pIter++;
641  parType id = pEntry.first;
642  double pv = pEntry.second;
643  switch( id ) {
644  case ptMin : phi->setPtMin ( pv ); break;
645  case etaMax : phi->setEtaMax ( pv ); break;
646  case massMin : phi->setMassMin( pv ); break;
647  case massMax : phi->setMassMax( pv ); break;
648  case probMin : phi->setProbMin( pv ); break;
649  case constrMass : phi->setConstr ( pv, phi->getConstrSigma() ); break;
650  case constrSigma: phi->setConstr ( phi->getConstrMass() , pv ); break;
651  case writeCandidate: writePkk = ( pv > 0 ); break;
652  default: break;
653  }
654  }
655  }
656  lPhi = phi->build();
657  delete phi;
658  }
659 
660  int nPhi = lPhi.size();
661 
662  // build and dump Bs
663 
664  if ( recoBs && nPhi ) {
665 
666  BPHBsToJPsiPhiBuilder* bs = new BPHBsToJPsiPhiBuilder( es, lJPsi, lPhi );
667  rIter = parMap.find( Bs );
668  if ( rIter != rIend ) {
669  const map<parType,double>& pMap = rIter->second;
670  map<parType,double>::const_iterator pIter = pMap.begin();
671  map<parType,double>::const_iterator pIend = pMap.end();
672  while ( pIter != pIend ) {
673  const map<parType,double>::value_type& pEntry = *pIter++;
674  parType id = pEntry.first;
675  double pv = pEntry.second;
676  switch( id ) {
677  case mPsiMin : bs->setJPsiMassMin( pv ); break;
678  case mPsiMax : bs->setJPsiMassMax( pv ); break;
679  case mPhiMin : bs->setPhiMassMin ( pv ); break;
680  case mPhiMax : bs->setPhiMassMax ( pv ); break;
681  case massMin : bs->setMassMin ( pv ); break;
682  case massMax : bs->setMassMax ( pv ); break;
683  case probMin : bs->setProbMin ( pv ); break;
684  case mFitMin : bs->setMassFitMin ( pv ); break;
685  case mFitMax : bs->setMassFitMax ( pv ); break;
686  case constrMJPsi: bs->setConstr ( pv > 0 ); break;
687  case writeCandidate: writeBs = ( pv > 0 ); break;
688  default: break;
689  }
690  }
691  }
692 
693  lBs = bs->build();
694  delete bs;
695 
696  set<BPHRecoConstCandPtr> sPhi;
697  int iBs;
698  int nBs = lBs.size();
699  for ( iBs = 0; iBs < nBs; ++iBs ) sPhi.insert( lBs[iBs]->getComp( "Phi" ) );
700  set<BPHRecoConstCandPtr>::const_iterator iter = sPhi.begin();
701  set<BPHRecoConstCandPtr>::const_iterator iend = sPhi.end();
702  while ( iter != iend ) lSs.push_back( *iter++ );
703 
704  }
705 
706  return;
707 
708 }
709 
710 
712  return;
713 }
714 
715 
717 
718  const string& name = ps.getParameter<string>( "name" );
719  bool writeCandidate = ps.getParameter<bool>( "writeCandidate" );
720  switch( rMap[name] ) {
721  case Onia: recoOnia = true; writeOnia = writeCandidate; break;
722  case Pmm:
723  case Psi1:
724  case Psi2:
725  case Ups:
726  case Ups1:
727  case Ups2:
728  case Ups3: recoOnia = true; break;
729  case Kx0 : recoKx0 = true; writeKx0 = writeCandidate; break;
730  case Pkk : recoPkk = true; writePkk = writeCandidate; break;
731  case Bu : recoBu = true; writeBu = writeCandidate; break;
732  case Bd : recoBd = true; writeBd = writeCandidate; break;
733  case Bs : recoBs = true; writeBs = writeCandidate; break;
734  }
735 
736  map<string,parType>::const_iterator pIter = pMap.begin();
737  map<string,parType>::const_iterator pIend = pMap.end();
738  while ( pIter != pIend ) {
739  const map<string,parType>::value_type& entry = *pIter++;
740  const string& pn = entry.first;
741  parType id = entry.second;
742  double pv = ps.getParameter<double>( pn );
743  if ( pv > -1.0e35 ) edm::LogVerbatim( "Configuration" )
744  << "BPHWriteSpecificDecay::setRecoParameters: set " << pn
745  << " for " << name << " : "
746  << ( parMap[rMap[name]][id] = pv );
747  }
748 
749  map<string,parType>::const_iterator fIter = fMap.begin();
750  map<string,parType>::const_iterator fIend = fMap.end();
751  while ( fIter != fIend ) {
752  const map<string,parType>::value_type& entry = *fIter++;
753  const string& fn = entry.first;
754  parType id = entry.second;
755  edm::LogVerbatim( "Configuration" )
756  << "BPHWriteSpecificDecay::setRecoParameters: set " << fn
757  << " for " << name << " : "
758  << ( parMap[rMap[name]][id] =
759  ( ps.getParameter<bool>( fn ) ? 1 : -1 ) );
760  }
761 
762 }
763 
765 
virtual void produce(edm::Event &ev, const edm::EventSetup &es)
Analysis-level particle class.
type
Definition: HCALResponse.h:21
void setEtaMax(double eta)
double getConstrSigma() const
static bool sameTrack(const reco::Candidate *lCand, const reco::Candidate *rCand, double minPDifference)
T getParameter(std::string const &) const
std::vector< BPHRecoConstCandPtr > build()
build Bu candidates
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
void setJPsiMassMin(double m)
set cuts
void setMassMax(oniaType type, double m)
virtual const pat::CompositeCandidate & composite() const
get a composite by the simple sum of simple particles
double getConstrMass(oniaType type) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void setPtMin(double pt)
set cuts
void setJPsiMassMin(double m)
set cuts
void setKPtMin(double pt)
set cuts
void setMassFitMax(double m)
void setKEtaMax(double eta)
void setMassMin(double m)
bool ev
void setProbMin(double p)
void setPtMin(double pt)
set cuts
double getConstrMass() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const Point & position() const
position
Definition: Vertex.h:109
#define SET_PAR(TYPE, NAME, PSET)
virtual size_type numberOfDaughters() const
number of daughters
virtual const std::vector< const reco::Candidate * > & daughters() const
virtual void fill(edm::Event &ev, const edm::EventSetup &es)
void setProbMin(oniaType type, double p)
static BPHGenericCollection * createCollection(const edm::Handle< T > &collection, const std::string &list="cfhpmig")
std::vector< BPHPlusMinusConstCandPtr > build()
build Phi candidates
U second(std::pair< T, U > const &p)
int TrackCharge
Definition: TrackCharge.h:4
BPHWriteSpecificDecay(const edm::ParameterSet &ps)
double getConstrSigma(oniaType type) const
void setEtaMax(double eta)
def pv(vc)
Definition: MetAnalyzer.py:6
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
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
void setProbMin(double p)
void setMassFitMin(double m)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
virtual const reco::Candidate * originalReco(const reco::Candidate *daug) const
get the original particle from the clone
void setMassMin(double m)
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
void setMassMax(double m)
double getConstrSigma() const
auto dp
Definition: deltaR.h:22
void setJPsiMassMin(double m)
set cuts
const T & get() const
Definition: EventSetup.h:55
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< BPHPlusMinusConstCandPtr > build()
build resonance candidates
void setConstr(double mass, double sigma)
void setConstr(oniaType type, double mass, double sigma)
void setEtaMax(oniaType type, double eta)
std::vector< BPHPlusMinusConstCandPtr > getList(oniaType type, BPHRecoSelect *dSel=0, BPHMomentumSelect *mSel=0, BPHVertexSelect *vSel=0, BPHFitSelect *kSel=0)
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:144
std::vector< BPHRecoConstCandPtr > build()
build Bs candidates
void setMassMax(double m)
def write(self, setup)
virtual const reco::Candidate * getDaug(const std::string &name) const
void setMassMin(oniaType type, double m)
Analysis-level muon class.
Definition: Muon.h:49
virtual std::pair< GlobalPoint, GlobalPoint > points() const
void setRecoParameters(const edm::ParameterSet &ps)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void setPtMin(oniaType type, double pt)
set cuts
std::vector< BPHRecoConstCandPtr > build()
build Bs candidates
void setConstr(double mass, double sigma)
void setJPsiMassMax(double m)
double getConstrMass() const
virtual const reco::Vertex & vertex() const
get reconstructed vertex
std::vector< BPHPlusMinusConstCandPtr > build()
build Phi candidates