//-------------------------------------------------------------------------- // File and Version Information: // $Id: BToDlnuXFilter.cc,v 1.5 2004/01/04 20:20:05 lange Exp $ // // Description: // Apply lepton preselection for B->Dlnu selection analysis. // // Environment: // Software developed for the BaBar Detector at the SLAC B-Factory. // // Author List: // Paul Jackson Original Author // // Copyright Information: // Copyright (C) 2002 UVIC // //------------------------------------------------------------------------ #include "BaBar/BaBar.hh" //----------------------- // This Class's Header -- //----------------------- #include "FilterTools/BToDlnuXFilter.hh" // also defines the class variables //------------- // C Headers -- //------------- #include //--------------- // C++ Headers -- //--------------- #include #include //------------------------------- // Collaborating Class Headers -- //------------------------------- #include "AbsEnv/AbsEnv.hh" #include "AbsEvent/AbsEvent.hh" #include "AbsEvent/AbsEventID.hh" #include "AbsEvent/getTmpAList.hh" #include "AbsEventTag/AbsEventTag.hh" #include "BbrStdUtils/String.hh" #include "Beta/BtaCandidate.hh" #include "Beta/EventInfo.hh" #include "BetaTools/BtaSemilepCand.hh" #include "CLHEP/Alist/ConstAList.h" #include "ErrLogger/ErrLog.hh" #include "GenEnv/GenEnv.hh" #include "HepTuple/HTValOrderedVector.h" #include "PDT/Pdt.hh" #include "PDT/PdtEntry.hh" #include "PDT/PdtLund.hh" //#include "ProxyDict/IfdHepAList.hh" #include "ProxyDict/IfdStrKey.hh" #include "ProxyDict/IfdKey.hh" #include "ProxyDict/Ifd.hh" #include #include //----------------------------------------------------------------------- // Local Macros, Typedefs, Structures, Unions and Forward Declarations -- //----------------------------------------------------------------------- //---------------- // Constructors -- //---------------- // in general, a module constructor should not do much. The begin(job) or // begin(run) members are better places to put initialization // // This ctor initializes the three sample list-name parameters BToDlnuXFilter::BToDlnuXFilter( const char* const theName, const char* const theDescription ) : APPFilterModule( theName, theDescription ) , _eventInfoList( "eventInfoList", this, "Default" ) , _chargedList( "chargedList", this, "GoodTracksVeryLoose") , _pidTrkList( "pidTrkList", this, "ChargedTracks") , _btaTruthList( "truthCandidates", this, "MCTruth" ) , _compDDstarLList( "compDDstarLList", this, "BToDorDstarlnuAll") , _pstarLeptonMin( "pstarLeptonMin", this, 0.8) , _pstarLeptonMax( "pstarLeptonMax", this, 3.0) , _requireLepton( "requireLepton", this, true) , _requireDlnu( "requireDlnu", this, true) , _passAllEvents( "passAllEvents", this, false) , _outputList( "outputList", this, "BToDlnuSkimmedList") , _booster() { commands()->append( &_eventInfoList ); commands()->append( &_chargedList); commands()->append( &_pidTrkList); commands()->append( &_btaTruthList); commands()->append( &_compDDstarLList); commands()->append( &_pstarLeptonMin); commands()->append( &_pstarLeptonMax); commands()->append( &_requireLepton); commands()->append( &_requireDlnu); commands()->append( &_passAllEvents); commands()->append( &_outputList); } //-------------- // Destructor -- //-------------- // The destructor should be limited to undoing the work of the constructor BToDlnuXFilter::~BToDlnuXFilter( ) { } //-------------- // Operations -- //-------------- // The begin(AppJob*) member function is run before any events are // processed. AppResult BToDlnuXFilter::beginJob( AbsEvent* anEvent ) { ErrMsg(routine)<<"begin Job"<* outputList; getTmpAList( anEvent, outputList, _outputList.value() ); assert( outputList!=0 ); HepAList< EventInfo >* infoList=0; getTmpAList(anEvent, infoList,_eventInfoList.value()); EventInfo* eventInfo = infoList->first(); if ( eventInfo == 0 ) { return false; } _nTrials++; AbsEventTag* tag = Ifd::get( anEvent ); if( 0 == tag ) return false; double pdgUpsMass= Pdt::lookup("Upsilon(4S)")->mass(); HepLorentzVector p4CM = eventInfo->cmFrame(); _booster.setLorentzVector(eventInfo->cmFrame()); HepAList* chargedList; getTmpAList (anEvent, chargedList, _chargedList.value()); HepAListIterator chargedIterator(*chargedList); HepAList* pidTrkList; getTmpAList (anEvent, pidTrkList, _pidTrkList.value()); HepAListIterator pidTrkIterator(*pidTrkList); HepAList* compDDstarLList; getTmpAList (anEvent, compDDstarLList, _compDDstarLList.value()); if (compDDstarLList->length()==0 && _requireDlnu.value()) { return false;} // save MC info BtaMcAssoc* truthMap = Ifd< BtaMcAssoc >::get( anEvent, "Micro" ); bool mcTruth(truthMap != 0); // particle id maps IfdStrKey muonKey(std::string("muSelectorsMap")); std::map* muSelectorsMap = Ifd< std::map >::get(anEvent,muonKey); IfdStrKey elecKey(std::string("eSelectorsMap")); std::map* eSelectorsMap = Ifd >::get(anEvent,elecKey); IfdStrKey kaonKey(std::string("KSelectorsMap")); std::map* KSelectorsMap = Ifd >::get(anEvent,kaonKey); IfdStrKey pionKey(std::string("piSelectorsMap")); std::map* piSelectorsMap = Ifd >::get(anEvent,pionKey); BtaCandidate* cand(0); bool foundMuon(false); bool foundElectron(false); bool foundLepton(false); while( cand = chargedIterator()) { const BtaCandidate boosted(_booster.boostTo(*cand)); if(boosted.p4().rho() < _pstarLeptonMin.value() || boosted.p4().rho() > _pstarLeptonMax.value()) continue; // we need to get the pointer to this track in the pidTrkList in // order to use the bitmaps, hence the following loop pidTrkIterator.rewind(); BtaCandidate* pidTrk(0); bool foundIt(false); while(pidTrk = pidTrkIterator()) { if(pidTrk->uid() == cand->uid()) { foundIt = true; break; } } assert(foundIt); if(muSelectorsMap!=0) { // muon map int tempInt(-1); std::map::const_iterator iterator = muSelectorsMap->find(pidTrk); if (iterator != muSelectorsMap->end()) { // this exists in the map; find the value int tempInt = iterator->second; } if(tempInt >> 3 & 0x1) foundLepton=true; // tight id foundMuon=true; } if(eSelectorsMap!=0) { // electron map int tempInt(-1); std::map::const_iterator iterator = eSelectorsMap->find(pidTrk); if (iterator != eSelectorsMap->end()) { // this exists in the map; find the value int tempInt = iterator->second; } if(tempInt >> 5 & 0x1) foundLepton=true; // pid likelihood selector foundElectron=true; } if(!foundLepton && _requireLepton.value()) { // failed lepton keep track of the statistics at this point. _cutLepton++; return false;} } int goodDLnuCandidates=0; int D0KPilnu=0, D0K3Pilnu=0, D0KPiPi0lnu=0, D0KsPiPilnu=0, Dstar0D0Pi0KPilnu=0, Dstar0D0Pi0K3Pilnu=0, Dstar0D0Pi0KPiPi0lnu=0, Dstar0D0Pi0KsPiPilnu=0, DchKPiPilnu=0, DchKsPilnu=0, DstarD0PiKPilnu=0, DstarD0PiK3Pilnu=0, DstarD0PiKPiPi0lnu=0, DstarD0PiKsPiPilnu=0, DstarDchPi0KPiPilnu=0, DstarDchPi0KsPilnu=0; bool isD0KPilnu=false,isD0K3Pilnu=false,isD0KPiPi0lnu=false,isD0KsPiPilnu=false,isDstar0D0Pi0KPilnu=false,isDstar0D0Pi0K3Pilnu=false,isDstar0D0Pi0KPiPi0lnu=false,isDstar0D0Pi0KsPiPilnu=false,isDchKPiPilnu=false,isDchKsPilnu=false,isDstarD0PiKPilnu=false,isDstarD0PiK3Pilnu=false,isDstarD0PiKPiPi0lnu=false,isDstarD0PiKsPiPilnu=false,isDstarDchPi0KPiPilnu=false,isDstarDchPi0KsPilnu=false; bool isD0lnu=false,isDchlnu=false,isDstarlnu=false,isDstar0lnu=false; HTValOrderedVector DLdType, DLd0Mode, DLdstarMode; HTValOrderedVector DLpLepton, DLcosBY; int DlnuLevel=0; HepAListIterator iterCompDDstarL(*compDDstarLList); while ( cand = iterCompDDstarL()) { BtaSemilepCand dhadl(*cand, p4CM); if(mcTruth) { dhadl.fillMcCache(truthMap); dhadl.resolveMcAssoc(); } bool isDstar(dhadl.theDstar()!=0); DLdType.append(isDstar); DLpLepton.append(dhadl.leptonPstar()); const BtaCandidate* lepton=dhadl.theLepton(); const BtaCandidate* hadron=dhadl.theHadron(); int dDecayMode(dhadl.getDDecayMode()); DLd0Mode.append(dDecayMode); int dstarDecayMode(dhadl.getDstarDecayMode()); DLdstarMode.append(dstarDecayMode); // This is included just to explicitly show which integers //correspond to which modes in BtaSemilepCand.cc. // dstarDecayMode = 1; //DstarToD0pi // dstarDecayMode = 2; //DstarToDchpi0 // dstarDecayMode = 3; //DstarToDchgamma.....we don't use this // dstarDecayMode = 4; //Dstar0ToD0pi0 // dstarDecayMode = 5; //Dstar0ToD0gamma.....we don't use this //Now lets see which of the DL candidates are in the list. if(dDecayMode == 1 && dstarDecayMode == 0) { DlnuLevel=1; D0KPilnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 2 && dstarDecayMode == 0) { DlnuLevel=1; D0K3Pilnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 3 && dstarDecayMode == 0) { DlnuLevel=1; D0KPiPi0lnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 4 && dstarDecayMode == 0) { DlnuLevel=1; D0KsPiPilnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 1 && dstarDecayMode == 4) { DlnuLevel=4; Dstar0D0Pi0KPilnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 2 && dstarDecayMode == 4) { DlnuLevel=4; Dstar0D0Pi0K3Pilnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 3 && dstarDecayMode == 4) { DlnuLevel=4; Dstar0D0Pi0KPiPi0lnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 4 && dstarDecayMode == 4) { DlnuLevel=4; Dstar0D0Pi0KsPiPilnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 5 && dstarDecayMode == 0) { DlnuLevel=2; DchKPiPilnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 7 && dstarDecayMode == 0) { DlnuLevel=2; DchKsPilnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 1 && dstarDecayMode == 1) { DlnuLevel=3; DstarD0PiKPilnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 2 && dstarDecayMode == 1) { DlnuLevel=3; DstarD0PiK3Pilnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 3 && dstarDecayMode == 1) { DlnuLevel=3; DstarD0PiKPiPi0lnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 4 && dstarDecayMode == 1) { DlnuLevel=3; DstarD0PiKsPiPilnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 5 && dstarDecayMode == 2) { DlnuLevel=3; DstarDchPi0KPiPilnu = 1; outputList->append( new BtaCandidate(*cand) ); } else if(dDecayMode == 7 && dstarDecayMode == 2) { DlnuLevel=3; DstarDchPi0KsPilnu = 1; outputList->append( new BtaCandidate(*cand) ); } else { cout << "Problem NO CANDIDATES FOUND FOR B->Dlnu skim" << endl; } if(D0KPilnu==1) isD0KPilnu=true; if(D0K3Pilnu==1) isD0K3Pilnu=true; if(D0KPiPi0lnu==1) isD0KPiPi0lnu=true; if(D0KsPiPilnu==1) isD0KsPiPilnu=true; if(Dstar0D0Pi0KPilnu==1) isDstar0D0Pi0KPilnu=true; if(Dstar0D0Pi0K3Pilnu==1) isDstar0D0Pi0K3Pilnu=true; if(Dstar0D0Pi0KPiPi0lnu==1) isDstar0D0Pi0KPiPi0lnu=true; if(Dstar0D0Pi0KsPiPilnu==1) isDstar0D0Pi0KsPiPilnu=true; if(DchKPiPilnu==1) isDchKPiPilnu=true; if(DchKsPilnu==1) isDchKsPilnu=true; if(DstarD0PiKPilnu==1) isDstarD0PiKPilnu=true; if(DstarD0PiK3Pilnu==1) isDstarD0PiK3Pilnu=true; if(DstarD0PiKPiPi0lnu==1) isDstarD0PiKPiPi0lnu=true; if(DstarD0PiKsPiPilnu==1) isDstarD0PiKsPiPilnu=true; if(DstarDchPi0KPiPilnu==1) isDstarDchPi0KPiPilnu=true; if(DstarDchPi0KsPilnu==1) isDstarDchPi0KsPilnu=true; if(DlnuLevel==1) isD0lnu=true; if(DlnuLevel==2) isDchlnu=true; if(DlnuLevel==3) isDstarlnu=true; if(DlnuLevel==4) isDstar0lnu=true; } _nSuccesses++; return true; } AppResult BToDlnuXFilter::endJob( AbsEvent* anEvent ) { ErrMsg(routine)<<" end Job" << endmsg; // Print statistics if ( ErrLogging(routine) ) { int passLepton=_nTrials-_cutLepton; ostream& os = ErrMsg(routine); os << endl << "===========================================" << endl << " Select candidates selection in " << name() << endl << "===========================================" << endl; os << "---- " << _nTrials << "\ttotal Candidates" << endl; os << "---- " << _nSuccesses << "\tselected Candidates" << endl; os << "---- " << _cutLepton << "\tcut Leptons" << endl; if(_nTrials>0) os << "---- " << ((double) _nSuccesses)/_nTrials << "\tFraction" << endl; os << "---- " << passLepton << "\tAfter lepton cut" << endl; os << "---- passAllEvents is " << _passAllEvents.value() << endl; os << endmsg; } return AppResult::OK; }