@@ -72,26 +72,26 @@ Description: [one line class summary]
7272using namespace std ;
7373
7474//
75- // Constans
75+ // Constants
7676//
7777
7878const int MUONMINUS_PDG_ID = 13 ;
7979// const int PIONPLUS_PDG_ID = 211;
8080// const int KLONGZERO_PDG_ID = 130;
8181// const int KSHORTZERO_PDG_ID = 310;
8282// const int KZERO_PDG_ID = 311;
83- const int KPLUS_PDG_ID = 323 ;
83+ const int KPLUS_PDG_ID = 321 ;
8484const int BPLUS_PDG_ID = 521 ;
8585const int JPSI_PDG_ID = 443 ;
86- const int PSI2S_PDG_ID = 10443 ;
86+ const int PSI2S_PDG_ID = 100443 ;
8787
8888const int ETA_PDG_ID = 221 ;
8989const int DZERO_PDG_ID = 421 ;
9090const int DSTAR2007_PDG_ID = 423 ;
9191const int DSPLUS_PDG_ID = 431 ;
9292const int DS1PLUS2460_PDG_ID = 20433 ;
9393const int SIGMACSTARPLUSPLUS_PDG_ID = 4224 ;
94- const int DELTAPLUS_PDG_ID = 2224 ;
94+ const int DELTAPLUS_PDG_ID = 2214 ;
9595
9696const double PI = 3.141592653589793 ;
9797
@@ -105,6 +105,7 @@ struct HistArgs{
105105};
106106
107107enum HistName{
108+ h_events, /* added */
108109 h_mupt,
109110 h_mueta,
110111 h_mumdcabs,
@@ -123,7 +124,7 @@ enum HistName{
123124 h_bvtxchisq,
124125 h_bvtxcl,
125126
126- h_Kmass,
127+ // h_Kmass,
127128 h_bmass,
128129
129130 kHistNameSize
@@ -134,6 +135,7 @@ enum HistName{
134135HistArgs hist_args[kHistNameSize ] = {
135136 // name, title, n_bins, x_min, x_max
136137
138+ {" h_events" , " Processed Events" , 1 , 0 , 1 }, /* added */
137139 {" h_mupt" , " Muon pT; [GeV]" , 100 , 0 , 30 },
138140 {" h_mueta" , " Muon eta" , 100 , 0 , 3 },
139141 {" h_mumdcabs" , " #mu^{-} DCA beam spot; DCA [cm]" , 100 , 0 , 10 },
@@ -153,7 +155,7 @@ HistArgs hist_args[kHistNameSize] = {
153155 {" h_bvtxchisq" , " B decay vertex chisq" , 100 , 0 , 1000 },
154156 {" h_bvtxcl" , " B decay vertex CL" , 100 , 0 , 1 },
155157
156- {" h_Kmass" , " K mass; M(K*) [GeV/^{2}]" , 100 , 0 , 20 },
158+ // {"h_Kmass", "K mass; M(K*) [GeV/^{2}]", 100, 0, 20},
157159
158160 {" h_bmass" , " B mass; M(B) [GeV]" , 100 , 0 , 20 },
159161
@@ -198,6 +200,12 @@ class BToKMuMu : public edm::EDAnalyzer {
198200 double VxzCov, double VyzCov, double WxErr2, double WyErr2,
199201 double WzErr2, double WxyCov, double WxzCov, double WyzCov,
200202 double * cosAlpha, double * cosAlphaErr);
203+
204+ void computeCosAlpha2D (double , double , double , double , double , /* added */
205+ double , double , double , double , double ,
206+ double , double , double , double ,
207+ double , double , double , double ,
208+ double *, double *);
201209
202210 void computeCtau (RefCountedKinematicTree, double &, double &);
203211 double computeEta (double , double , double );
@@ -255,6 +263,7 @@ class BToKMuMu : public edm::EDAnalyzer {
255263 void saveBuToKMuMu (RefCountedKinematicTree);
256264 void saveBuVertex (RefCountedKinematicTree);
257265 void saveBuCosAlpha (RefCountedKinematicTree);
266+ void saveBuCosAlpha2D (RefCountedKinematicTree); /* added */
258267 void saveBuLsig (RefCountedKinematicTree);
259268 void saveBuCtau (RefCountedKinematicTree);
260269
@@ -376,7 +385,7 @@ class BToKMuMu : public edm::EDAnalyzer {
376385 vector<double > *bpx, *bpxerr, *bpy, *bpyerr, *bpz, *bpzerr, *bmass, *bmasserr;
377386 vector<double > *bvtxcl, *bvtxx, *bvtxxerr, *bvtxy, *bvtxyerr, *bvtxz, *bvtxzerr;
378387 vector<double > *bcosalphabs, *bcosalphabserr, *blsbs, *blsbserr, *bctau, *bctauerr;
379-
388+ vector< double > *bcosalphabs2D, *bcosalphabs2Derr; /* added */
380389
381390 // For MC
382391 int genbchg; // +1 for b+, -1 for b-
@@ -396,6 +405,10 @@ class BToKMuMu : public edm::EDAnalyzer {
396405
397406 vector<bool > *istruemum, *istruemup, *istruetrk, *istruebu;
398407 // *istrueks,
408+
409+ TDatime t_begin_ , t_now_ ; /* added */
410+ int n_processed_, n_selected_;
411+
399412
400413};
401414
@@ -423,7 +436,7 @@ BToKMuMu::BToKMuMu(const edm::ParameterSet& iConfig):
423436 BuMass_(iConfig.getUntrackedParameter<double >(" BuMass" )),
424437
425438 // labels
426- // GenParticlesLabel_(iConfig.getParameter<edm::InputTag>("GenParticlesLabel")),
439+ GenParticlesLabel_(iConfig.getParameter<edm::InputTag>(" GenParticlesLabel" )),
427440 TriggerResultsLabel_(iConfig.getParameter<edm::InputTag>(" TriggerResultsLabel" )),
428441 BeamSpotLabel_(iConfig.getParameter<edm::InputTag>(" BeamSpotLabel" )),
429442 VertexLabel_(iConfig.getParameter<edm::InputTag>(" VertexLabel" )),
@@ -492,7 +505,7 @@ BToKMuMu::BToKMuMu(const edm::ParameterSet& iConfig):
492505 bmass(0 ), bmasserr(0 ),
493506 bvtxcl(0 ), bvtxx(0 ), bvtxxerr(0 ), bvtxy(0 ), bvtxyerr(0 ), bvtxz(0 ), bvtxzerr(0 ),
494507 bcosalphabs(0 ), bcosalphabserr(0 ), blsbs(0 ), blsbserr(0 ), bctau(0 ), bctauerr(0 ),
495-
508+ bcosalphabs2D( 0 ), bcosalphabs2Derr( 0 ), /* added */
496509
497510
498511 genbchg(0 ),
@@ -536,6 +549,10 @@ BToKMuMu::~BToKMuMu()
536549void
537550BToKMuMu::analyze (const edm::Event& iEvent, const edm::EventSetup& iSetup)
538551{
552+
553+ n_processed_ += 1 ;
554+ histos[h_events]->Fill (0 );
555+
539556 clearVariables ();
540557
541558 run = iEvent.id ().run () ;
@@ -555,7 +572,9 @@ BToKMuMu::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
555572
556573 if (IsMonteCarlo_) saveTruthMatch (iEvent);
557574
558- tree_->Fill ();
575+ tree_->Fill ();
576+ n_selected_ += 1 ; /* added */
577+
559578 }
560579 }
561580
@@ -567,6 +586,15 @@ BToKMuMu::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
567586void
568587BToKMuMu::beginJob ()
569588{
589+
590+ t_begin_.Set ();
591+ printf (" \n ---------- Begin Job ---------- \n " ); /* added */
592+ t_begin_.Print ();
593+
594+ n_processed_ = 0 ;
595+ n_selected_ = 0 ;
596+
597+
570598 fout_ = new TFile (OutputFileName_.c_str (), " RECREATE" );
571599 fout_->cd ();
572600
@@ -679,6 +707,8 @@ BToKMuMu::beginJob()
679707 tree_->Branch (" bvtxzerr" , &bvtxzerr);
680708 tree_->Branch (" bcosalphabs" , &bcosalphabs);
681709 tree_->Branch (" bcosalphabserr" , &bcosalphabserr);
710+ tree_->Branch (" bcosalphabs2D" , &bcosalphabs2D); /* added */
711+ tree_->Branch (" bcosalphabs2Derr" , &bcosalphabs2Derr);
682712 tree_->Branch (" blsbs" , &blsbs);
683713 tree_->Branch (" blsbserr" , &blsbserr);
684714 tree_->Branch (" bctau" , &bctau);
@@ -742,6 +772,17 @@ BToKMuMu::endJob()
742772 histos[i]->Delete ();
743773 }
744774 fout_->Close ();
775+
776+ t_now_.Set ();
777+ printf (" \n ---------- End Job ---------- \n " ) ; /* added */
778+ t_now_.Print ();
779+ printf (" processed: %i \n selected: %i \n \
780+ duration: %i sec \n rate: %g evts/sec\n " ,
781+ n_processed_, n_selected_,
782+ t_now_.Convert () - t_begin_.Convert (),
783+ float (n_processed_)/(t_now_.Convert ()-t_begin_.Convert ()) );
784+
785+
745786}
746787
747788// method called when starting to processes a run ------------
@@ -830,6 +871,7 @@ BToKMuMu::clearVariables(){
830871 bvtxyerr->clear ();
831872 bvtxz->clear (); bvtxzerr->clear (); bcosalphabs->clear (); bcosalphabserr->clear ();
832873 blsbs->clear (); blsbserr->clear (); bctau->clear (); bctauerr->clear ();
874+ bcosalphabs2D->clear (); bcosalphabs2Derr->clear (); /* added */
833875
834876 if (IsMonteCarlo_) {
835877 genbchg = 0 ; genbpx = 0 ; genbpy = 0 ; genbpz = 0 ;
@@ -948,7 +990,7 @@ BToKMuMu::buildBuToKMuMu(const edm::Event& iEvent)
948990 // init variables
949991 edm::Handle< vector<pat::Muon> > patMuonHandle;
950992 iEvent.getByLabel (MuonLabel_, patMuonHandle);
951- if ( patMuonHandle->size () < 2 ) return ;
993+ if ( patMuonHandle->size () < 2 ) return ;
952994
953995 /*
954996 edm::Handle<reco::VertexCompositeCandidateCollection> theKshorts;
@@ -968,7 +1010,8 @@ BToKMuMu::buildBuToKMuMu(const edm::Event& iEvent)
9681010 double MuMuCosAlphaBS, MuMuCosAlphaBSErr;
9691011 // double K_mass
9701012 double kaon_trk_pt, b_vtx_chisq, b_vtx_cl, b_mass;
971- // double DCAKstTrkBS, DCAKstTrkBSErr;
1013+ // double DCAKstTrkBS, DCAKstTrkBSErr;
1014+ double DCAKaonTrkBS, DCAKaonTrkBSErr; /* added */
9721015 // vector<reco::TrackRef> kshortDaughterTracks;
9731016 RefCountedKinematicTree vertexFitTree;
9741017 // RefCountedKinematicTree ksVertexFitTree;
@@ -1053,7 +1096,7 @@ BToKMuMu::buildBuToKMuMu(const edm::Event& iEvent)
10531096 */
10541097
10551098 // ---------------------------------
1056- // loop 4: track
1099+ // loop 3: Kaon track
10571100 // ---------------------------------
10581101 for ( vector<pat::GenericParticle>::const_iterator iTrack
10591102 = thePATTrackHandle->begin ();
@@ -1071,6 +1114,11 @@ BToKMuMu::buildBuToKMuMu(const edm::Event& iEvent)
10711114 histos[h_trkdcasigbs]->Fill(DCAKstTrkBS/DCAKstTrkBSErr);
10721115 if (!passed) continue;
10731116 */
1117+ passed = hasGoodTrackDcaBs (theTrackTT, DCAKaonTrkBS, DCAKaonTrkBSErr); /* added */
1118+ histos[h_trkdcasigbs]->Fill (DCAKaonTrkBS/DCAKaonTrkBSErr);
1119+ if (!passed) continue ;
1120+
1121+
10741122
10751123 passed = hasGoodBuVertex (muTrackm, muTrackp,
10761124 kaonTrack, b_vtx_chisq, b_vtx_cl,
@@ -1100,8 +1148,8 @@ BToKMuMu::buildBuToKMuMu(const edm::Event& iEvent)
11001148 // saveKshortVariables(ksVertexFitTree, *iKshort);
11011149
11021150 trkpt->push_back (kaon_trk_pt);
1103- // trkdcabs->push_back(DCAKstTrkBS );
1104- // trkdcabserr->push_back(DCAKstTrkBSErr );
1151+ trkdcabs->push_back (DCAKaonTrkBS );
1152+ trkdcabserr->push_back (DCAKaonTrkBSErr );
11051153 // Kmass->push_back(K_mass);
11061154 bchg->push_back (iTrack->charge ());
11071155 bvtxcl->push_back (b_vtx_cl);
@@ -1110,16 +1158,18 @@ BToKMuMu::buildBuToKMuMu(const edm::Event& iEvent)
11101158 saveBuToKMuMu (vertexFitTree);
11111159 saveBuVertex (vertexFitTree);
11121160 saveBuCosAlpha (vertexFitTree);
1161+ saveBuCosAlpha2D (vertexFitTree); /* added */
11131162 saveBuLsig (vertexFitTree);
11141163 saveBuCtau (vertexFitTree);
11151164
1116- } // close track loop
1165+ } // close kaon track loop
11171166 // } // close kshort loop
11181167 } // close mu+ loop
11191168 } // close mu- loop
11201169
1121- if ( nb > 0 ) edm::LogInfo (" myBu" ) << " Found " << nb << " Bu -> K+ mu mu." ;
1122-
1170+ if ( nb > 0 )
1171+ edm::LogInfo (" myBu" ) << " Found " << nb << " Bu -> K+ mu mu." ;
1172+
11231173}
11241174
11251175
@@ -1192,6 +1242,48 @@ BToKMuMu::computeCosAlpha (double Vx, double Vy, double Vz,
11921242 }
11931243}
11941244
1245+ void
1246+ BToKMuMu::computeCosAlpha2D (double Vx, double Vy, double Vz, /* added */
1247+ double Wx, double Wy, double Wz,
1248+ double VxErr2, double VyErr2, double VzErr2,
1249+ double VxyCov, double VxzCov, double VyzCov,
1250+ double WxErr2, double WyErr2, double WzErr2,
1251+ double WxyCov, double WxzCov, double WyzCov,
1252+ double * cosAlpha2D, double * cosAlpha2DErr)
1253+
1254+ {
1255+ double Vnorm = sqrt (Vx*Vx + Vy*Vy + Vz*Vz);
1256+ double Wnorm = sqrt (Wx*Wx + Wy*Wy + Wz*Wz);
1257+ double VdotW = Vx*Wx + Vy*Wy + Vz*Wz;
1258+
1259+ if ((Vnorm > 0 .) && (Wnorm > 0 .)) {
1260+ *cosAlpha2D = VdotW / (Vnorm * Wnorm);
1261+
1262+ *cosAlpha2DErr = sqrt ( (
1263+ (Vx*Wnorm - VdotW*Wx) * (Vx*Wnorm - VdotW*Wx) * WxErr2 +
1264+ (Vy*Wnorm - VdotW*Wy) * (Vy*Wnorm - VdotW*Wy) * WyErr2 +
1265+ (Vz*Wnorm - VdotW*Wz) * (Vz*Wnorm - VdotW*Wz) * WzErr2 +
1266+
1267+
1268+ (Vx*Wnorm - VdotW*Wx) * (Vy*Wnorm - VdotW*Wy) * 2 .*WxyCov +
1269+ (Vx*Wnorm - VdotW*Wx) * (Vz*Wnorm - VdotW*Wz) * 2 .*WxzCov +
1270+ (Vy*Wnorm - VdotW*Wy) * (Vz*Wnorm - VdotW*Wz) * 2 .*WyzCov) /
1271+ (Wnorm*Wnorm*Wnorm*Wnorm) +
1272+
1273+ ((Wx*Vnorm - VdotW*Vx) * (Wx*Vnorm - VdotW*Vx) * VxErr2 +
1274+ (Wy*Vnorm - VdotW*Vy) * (Wy*Vnorm - VdotW*Vy) * VyErr2 +
1275+ (Wz*Vnorm - VdotW*Vz) * (Wz*Vnorm - VdotW*Vz) * VzErr2 +
1276+
1277+ (Wx*Vnorm - VdotW*Vx) * (Wy*Vnorm - VdotW*Vy) * 2 .*VxyCov +
1278+ (Wx*Vnorm - VdotW*Vx) * (Wz*Vnorm - VdotW*Vz) * 2 .*VxzCov +
1279+ (Wy*Vnorm - VdotW*Vy) * (Wz*Vnorm - VdotW*Vz) * 2 .*VyzCov) /
1280+ (Vnorm*Vnorm*Vnorm*Vnorm) ) / (Wnorm*Vnorm);
1281+ } else {
1282+ *cosAlpha2D = 0 .;
1283+ *cosAlpha2DErr = 0 .;
1284+ }
1285+ }
1286+
11951287
11961288bool
11971289BToKMuMu::hasGoodMuonDcaBs (const reco::TransientTrack muTrackTT,
@@ -1686,6 +1778,32 @@ BToKMuMu::saveBuCosAlpha(RefCountedKinematicTree vertexFitTree)
16861778}
16871779
16881780
1781+ void
1782+ BToKMuMu::saveBuCosAlpha2D (RefCountedKinematicTree vertexFitTree) /* added */
1783+ {
1784+
1785+ vertexFitTree->movePointerToTheTop ();
1786+ RefCountedKinematicParticle b_KP = vertexFitTree->currentParticle ();
1787+ RefCountedKinematicVertex b_KV = vertexFitTree->currentDecayVertex ();
1788+
1789+ double cosAlphaBS2D, cosAlphaBS2DErr;
1790+ computeCosAlpha2D (b_KP->currentState ().globalMomentum ().x (),
1791+ b_KP->currentState ().globalMomentum ().y (),0.0 ,
1792+ b_KV->position ().x () - beamSpot_.position ().x (),
1793+ b_KV->position ().y () - beamSpot_.position ().y (),0.0 ,
1794+ b_KP->currentState ().kinematicParametersError ().matrix ()(3 ,3 ),
1795+ b_KP->currentState ().kinematicParametersError ().matrix ()(4 ,4 ),0.0 ,
1796+ b_KP->currentState ().kinematicParametersError ().matrix ()(3 ,4 ),0.0 ,0.0 ,
1797+ b_KV->error ().cxx () + beamSpot_.covariance ()(0 ,0 ),
1798+ b_KV->error ().cyy () + beamSpot_.covariance ()(1 ,1 ),0.0 ,
1799+ b_KV->error ().matrix ()(0 ,1 ) + beamSpot_.covariance ()(0 ,1 ),0.0 ,0.0 ,
1800+ &cosAlphaBS2D,&cosAlphaBS2DErr);
1801+
1802+ bcosalphabs2D->push_back (cosAlphaBS2D);
1803+ bcosalphabs2Derr->push_back (cosAlphaBS2DErr);
1804+
1805+ }
1806+
16891807
16901808bool
16911809BToKMuMu::matchPrimaryVertexTracks ()
@@ -1865,21 +1983,21 @@ BToKMuMu::saveGenInfo(const edm::Event& iEvent){
18651983 // const reco::Candidate & pip = *(ks->daughter(ipip));
18661984 // const reco::Candidate & pim = *(ks->daughter(ipim));
18671985 // const reco::Candidate & kp = *(kst.daughter(ikp));
1868- const reco::Candidate & kp = *(b.daughter (ikp));
1986+ const reco::Candidate & kp = *(b.daughter (ikp));
18691987 const reco::Candidate *mum = NULL ;
18701988 const reco::Candidate *mup = NULL ;
18711989
1872- // K* mu mu
1990+ // K+ mu mu
18731991 if (imum != -1 && imup != -1 ) {
1874- // cout << "Found GEN B+-> K* mu mu " << endl;
1992+ // cout << "Found GEN B+-> K+ mu mu " << endl;
18751993 mum = b.daughter (imum);
18761994 mup = b.daughter (imup);
18771995 decname = " BuToKMuMu" ;
18781996 }
18791997
1880- // K* J/psi
1998+ // K+ J/psi
18811999 else if ( ijpsi != -1 ) {
1882- // cout << "Found GEN B+-> K* J/psi " << endl;
2000+ // cout << "Found GEN B+-> K+ J/psi " << endl;
18832001 const reco::Candidate & jpsi = *(b.daughter (ijpsi));
18842002 for ( size_t j = 0 ; j < jpsi.numberOfDaughters (); ++j){
18852003 const reco::Candidate &dau = *(jpsi.daughter (j));
@@ -1893,9 +2011,9 @@ BToKMuMu::saveGenInfo(const edm::Event& iEvent){
18932011 }
18942012 }
18952013
1896- // K* psi(2S)
2014+ // K+ psi(2S)
18972015 else if ( ipsi2s != -1 ) {
1898- // cout << "Found GEN B+-> K* psi(2S) " << endl;
2016+ // cout << "Found GEN B+-> K+ psi(2S) " << endl;
18992017 const reco::Candidate & psi2s = *(b.daughter (ipsi2s));
19002018 for ( size_t j = 0 ; j < psi2s.numberOfDaughters (); ++j){
19012019 const reco::Candidate &dau = *(psi2s.daughter (j));
@@ -2213,7 +2331,7 @@ BToKMuMu::saveTruthMatch(const edm::Event& iEvent){
22132331 istrueks->push_back(false);
22142332 }
22152333 */
2216- // truth match with pion track
2334+ // truth match with Kaon track
22172335 deltaEtaPhi = computeEtaPhiDistance (gentrkpx, gentrkpy, gentrkpz,
22182336 trkpx->at (i), trkpy->at (i), trkpz->at (i));
22192337 if (deltaEtaPhi < TruthMatchKaonMaxR_){
0 commit comments