Beispiel #1
0
int Tau::Rematch(Event *e,float dR){
    if (rematch_ >=0 ) return rematch_; // cache

    GenParticle * gp =NULL;
    int ig=0;
    bool isTau=false;
    bool isQuark=false;
    bool isGluon=false;
    bool isEle = false;
    bool isMuon= false;
    float hardestPt=-1.;
    bool isHardestQ = false;

    for (gp = e->GetGenParticle(ig) ; gp != NULL ; gp=e->GetGenParticle(++ig))
    {
        if  (gp->DeltaR(this) >dR) continue;
        //if  (gp->IsPromptFinalState() ) continue; // useless
        if  ( abs(gp->GetPdgId()) == 15 ) isTau = true; // I don't care the status
        if ( abs(gp->GetPdgId()) == 11) 
        {
            isEle = true;
        }
        if ( abs(gp->GetPdgId()) == 13) 
        {
            isMuon = true;
        }
        if ( abs(gp->GetPdgId() ) == 21 )
            {
            isGluon=true;
            if (hardestPt < gp->Pt() ) { hardestPt=gp->Pt(); isHardestQ=false;}
            }
        if ( abs(gp->GetPdgId() ) <= 4 )
            {
            isQuark=true;
            if (hardestPt < gp->Pt() ) { hardestPt=gp->Pt(); isHardestQ=true;}
            }
    }
    if (isTau) rematch_=15;
    //the additional check isQuark, prevent the default value on isHardest
    if (rematch_<0 and isMuon) rematch_=13;
    if (rematch_<0 and isEle) rematch_=11;
    if (rematch_ <0 and isQuark and isHardestQ) rematch_=1;
    if (rematch_ <0 and isGluon and not isHardestQ) rematch_=21;
    // no match
    if (rematch_ <0 ) rematch_=0;
    return rematch_;
}
Beispiel #2
0
bool Event::GenParticleDecayedFrom( int iGenPar, int apdgid ,int& idx){
    //if( apdgid==25) Logger::getInstance().Log("Event",__FUNCTION__,"DEBUG",Form("* Called GenParticleDecaydFrom %d",iGenPar) );//DEBUG
    GenParticle *g = GetGenParticle(iGenPar);
    if (g ==NULL)return false;
    //if( apdgid==25) Logger::getInstance().Log("Event",__FUNCTION__,"DEBUG",Form("*  ---> Current pdgId is %d",g->GetPdgId()) );//DEBUG
    if (abs(g->GetPdgId()) == apdgid) { idx=iGenPar; return true;}
    int moidx = g->GetParentIdx();
    if (moidx == iGenPar) return false;
    return GenParticleDecayedFrom( moidx, apdgid,idx);
}
Beispiel #3
0
GenParticle * Event::GetGenStable( int iGenPar ,int pdgid,float aeta) 
{  
    // status 1, electrons
    vector<pair<float,int> > valid; // pt, idx
    for(int i = 0 ; i<genparticles_.size() ;++i)
    {
        GenParticle *gp = genparticles_[i];
        if (not gp->IsPromptFinalState()  ) continue;
        if ( abs(gp->GetPdgId()) != pdgid)  continue;
        if ( fabs(gp->Eta() ) > aeta) continue;
        valid.push_back(pair<float,int>(gp->Pt(),i)); 
    }
    if (valid.size() == 0 ) return NULL;
    if (valid.size() <= iGenPar  ) return NULL;

    sort(valid.begin(),valid.end(),[](pair<float,int> &a,pair<float,int> &b) { if (a.first> b.first) return true; if (a.first<b.first) return false; return a.second<b.second;} ) ;

    return genparticles_[ valid[iGenPar].second];
}
void ChargedHiggsTauNu::analyzeGen(Event*e, string systname)
{
    // no systematics shifts for this
    if (systname !="" and systname != "NONE") return;

    string label = GetLabel(e);

    Weight* w = e->GetWeight();
    // make sure we don't book sf or corrections here
    double mcWeight=w->GetBareMCWeight() * w->GetBarePUWeight()* w->GetBareMCXsec() * w->GetBareLumi() / w->GetBareNevents();
    Fill("ChargedHiggsTauNu/Gen/CutFlow_"+label,systname,0,mcWeight);

    // find the H+
    int iHpm=-1;
    int iTau=-1;
    int iLFromTau=-1; // find leptonic taus
    int iIsoL = -1; // is there an isolated lepton ?
    for(unsigned i = 0 ; ;++i)
    {
        GenParticle *g = e->GetGenParticle(i);
        if (g==NULL) break; //exit condition

        int apdg = abs(g->GetPdgId());
        if (iHpm <0  and apdg == 37 ) { iHpm = i; }
        if (iTau <0 and apdg == 15 ) { iTau = i; }
        if (iLFromTau <0 and (apdg == 11 or apdg == 13) and e->GenParticleDecayedFrom(i,15) ) { iLFromTau = i; }
        if (iIsoL <0  and (apdg == 11 or apdg == 13) and g->IsPromptFinalState() and g->Pt() >10 and abs(g->Eta())<2.4){
            float iso = 0.0;
            for(unsigned j = 0 ; ;++j)
            {
                if (i == j ) continue; // no double counting;
                GenParticle *g2 = e->GetGenParticle(j);
                if (g2 == NULL) break;
                if (not g2->IsPromptFinalState()) continue;
                if (g2->IsDressed() ) continue; // no dressed leptons
                if (g2->DeltaR(g) >0.1)  continue;
                iso += g2->Pt();
            }
            if (iso<10) iIsoL = i;
        }

    }

    bool lepVeto=false;
    if (e->Nleps() ==0 ) lepVeto=true;
    else if( e->GetMuon(0) == NULL){ // no 10 GeV muon
        
        if (e->GetElectron(0) !=NULL and e->GetElectron(0)->Pt() <15) lepVeto=true; // pt ordered
    }

    vector<Lepton*> miniIsoLeptons;
    bool lepVetoMiniIso=true;
    for(unsigned il=0 ; ;++il)
    {
        Lepton *l = e->GetBareLepton(il);
        if (l == NULL) break;  // exit strategy
        
        // selection
        if (l->Pt() <10 ) continue;
        //l->SetIsoRelCut(0.25);
        if (abs(l->Eta()) >2.4) continue;
        //medium id
        if( not l->GetMediumId() ) continue;

        //MINI-ISO
        if( l->MiniIsolation() >0.4 ) continue;//loose

        // for muons require tracker and global
        if (l->IsMuonDirty() and not l->GetTrackerMuon())  continue;
        if (l->IsMuonDirty() and not l->GetGlobalMuon())  continue;

        // selected leptons
        miniIsoLeptons.push_back(l);
        lepVetoMiniIso=false;
    }
    // sort miniIsoLeptons by pt
    std::sort(miniIsoLeptons.begin(),miniIsoLeptons.end(),[](Lepton const *a, Lepton const *b ){return a->Pt() > b->Pt();});


    if (iHpm >=0 ) Fill("ChargedHiggsTauNu/Gen/CutFlow_"+label,systname,1,mcWeight);
    if (iHpm >=0 and iTau>=0 ) Fill("ChargedHiggsTauNu/Gen/CutFlow_"+label,systname,2,mcWeight);
    if (iHpm >=0 and iTau>=0 and iLFromTau<0){

        Fill("ChargedHiggsTauNu/Gen/CutFlow_"+label,systname,3,mcWeight);
        if (iIsoL <0) Fill("ChargedHiggsTauNu/Gen/CutFlow_"+label,systname,4,mcWeight);
        if (lepVeto) Fill("ChargedHiggsTauNu/Gen/CutFlow_"+label,systname,5,mcWeight);
        if (lepVetoMiniIso ) Fill("ChargedHiggsTauNu/Gen/CutFlow_"+label,systname,6,mcWeight);
    }

}
Beispiel #5
0
int DYAnalysis::analyzeMM(Event *e, string systname)
{
    string label = GetLabel(e);
    cut.reset();
    cut.SetMask(MaxCut-1) ;
    cut.SetCutBit( Total ) ;

    Lepton*mu0 = e->GetMuon(0);
    Lepton*mu1 = e->GetMuon(1);
    Jet *j0 = e->GetJet(0);
    Jet *j1 = e->GetJet(1);

    // Truth
    GenParticle *genmu0=NULL; GenParticle *genmu1=NULL;

    for( int iGen=0 ; /*empty*/ ; ++iGen)
    {
        GenParticle *g = e->GetGenParticle(iGen); 
        if (g==NULL ) break;  // end loop statement
        if (not g->IsDressed()) continue;
        if (not abs(g->GetPdgId())==13) continue;
        
        if (genmu0== NULL) genmu0=g;
        else if (genmu1==NULL) {genmu1=g; break;}
    }

    bool genMuons = genmu0!=NULL and genmu1 !=NULL;

    bool isGen=false;
    bool isReco=false;
    if (genMuons) // no requirement on pT
    {
        Object Ztruth(*genmu0); 
        Ztruth += *genmu1;
        if (Ztruth.M() > 60 and Ztruth.M()<120) isGen=true;
    }

    bool recoMuons= mu0 != NULL and mu1 !=NULL; 
    //if (not recoMuons) return 0;

    if (mu0!=NULL and mu0->Pt() > 25 and fabs(mu0->Eta())< 2.4) 
    {
        if (e->IsTriggered("HLT_IsoMu20") ) {
            Fill("DYAnalysis/Vars/MuonIso_"+ label,systname, mu0->Isolation(),e->weight()) ;
        }
    }

    if (recoMuons and mu1->Pt() >20)
    { // ------------------- 20 -------------------
        Object Z(*mu0);
        Z += *mu1;
        if (Z.M()> 60 && Z.M()<120){
            Fill("DYAnalysis/Vars/Pt20mm_"+ label,systname, Z.Pt(),e->weight()) ;
        }
    
    }

    // ---------------------- 25 -------------------
    if ( recoMuons and mu1->Pt() >25)
    {
        cut.SetCutBit(Leptons);
        if (e->IsTriggered("HLT_IsoMu20") ) cut.SetCutBit(Trigger);

        Object Z(*mu0);
        Z += *mu1;
       	if (cut.passAllUpTo(Trigger) ){
            Fill("DYAnalysis/Vars/Mmm_"+ label,systname, Z.M(),e->weight()) ;
        }

        if (Z.M()> 60 && Z.M()<120) cut.SetCutBit(Mass);

       	if (cut.passAll() ){
            Fill("DYAnalysis/Vars/Ptmm_"+ label,systname, Z.Pt(),e->weight()) ;
            Fill("DYAnalysis/Vars/EtaMu1_"+ label,systname, mu0->Eta(),e->weight()) ;
       	    Fill("DYAnalysis/Vars/Npvmm_"+ label,systname, e->Npv(),e->weight()) ;
            Fill("DYAnalysis/Vars/NJmm_"+ label,systname, e->NcentralJets(),e->weight()) ;
            Fill("DYAnalysis/Vars/PtmmUW_"+ label,systname, Z.Pt(),1.0) ;
            isReco=true;
        }

        if ( Z.Pt() > 500) // NoSingleMuon Trigger -> ISO
        {
            Fill( "DYAnalysis/Vars/MHighPtmm_" + label,systname,Z.M() ,e->weight() ) ;
            if( j1 != NULL ) Fill( "DYAnalysis/Vars/MJHighPtmm_" + label,systname, j1->InvMass(j0) ,e->weight() ) ;
        }

        if(mu0->DeltaR(mu1) <.8) {
	        Fill ("DYAnalysis/Vars/MCloseMt_"+ label , systname, ChargedHiggs::mt(Z.GetP4(), e->GetMet().GetP4()) , e->weight());
	        if (j0!=NULL)Fill ("DYAnalysis/Vars/MCloseJZ_"+ label,systname,j0->InvMass(&Z)  , e->weight());
        }
    }

    if (isReco and isGen) Fill("DYAnalysis/Vars/Accmm_"+label,systname, 0);
    else if ( isGen ) Fill("DYAnalysis/Vars/Accmm_"+label,systname, 1);
    else if ( isReco ) Fill("DYAnalysis/Vars/Accmm_"+label,systname, 2); 
    return 0;
}
Beispiel #6
0
int DYAnalysis::analyzeEE(Event *e, string systname)
{
    string label = GetLabel(e);
    cut.reset();
    cut.SetMask(MaxCut-1) ;
    cut.SetCutBit( Total ) ;

    if (e->weight() == 0.) Log(__FUNCTION__,"WARNING","Event Weight is NULL");

    Lepton*e0 = e->GetElectron(0);
    Lepton*e1 = e->GetElectron(1);
    Jet *j0 = e->GetJet(0);
    Jet *j1 = e->GetJet(1);

    bool recoEles = e0 !=NULL and e1 !=NULL;
    //if (e0 == NULL or e1 == NULL) return 0;

    GenParticle *genele0=NULL; GenParticle *genele1=NULL;

    for( int iGen=0 ; /*empty*/ ; ++iGen)
    {
        GenParticle *g = e->GetGenParticle(iGen); 
        if (g==NULL ) break;  // end loop statement
        if (not g->IsDressed()) continue;
        if (not abs(g->GetPdgId())==11) continue;
        
        if (genele0== NULL) genele0=g;
        else if (genele1==NULL) {genele1=g; break;}
    }

    bool genEles = genele0!=NULL and genele1 !=NULL;

    bool isGen=false;
    bool isReco=false;
    if (genEles) // no requirement on pT
    {
        Object Ztruth(*genele0); 
        Ztruth += *genele1;
        if (Ztruth.M() > 60 and Ztruth.M()<120) isGen=true;
    }

    if ( recoEles and e1->Pt() >25)
    {
        cut.SetCutBit(Leptons);
        //if (e->IsTriggered("HLT_Ele27_eta2p1_WPLoose_Gsf") ) cut.SetCutBit(Trigger);
        cut.SetCutBit(Trigger);
        Object Z(*e0);
        Z += *e1;
       	if (cut.passAllUpTo(Trigger))Fill("DYAnalysis/Vars/Mee_"+ label,systname ,Z.M(),e->weight()) ;

        if (Z.M()> 60 && Z.M()<120) cut.SetCutBit(Mass);

        if (cut.passAll()){
       	    Fill("DYAnalysis/Vars/Ptee_"+ label,systname, Z.Pt(),e->weight()) ;
            Fill("DYAnalysis/Vars/NJee_"+ label,systname, e->NcentralJets(),e->weight()) ;
       	    Fill("DYAnalysis/Vars/Npvee_"+ label,systname, e->Npv(),e->weight()) ;
            isReco=true;
        }

        if ( Z.Pt() > 500)
        {
            Fill( "DYAnalysis/Vars/MHighPtee_" + label,systname,Z.M() ,e->weight() ) ;
            if( j1 != NULL ) Fill( "DYAnalysis/Vars/MJHighPtee_" + label,systname, j1->InvMass(j0) ,e->weight() ) ;
        }
    }

    if (isReco and isGen) Fill("DYAnalysis/Vars/Accee_"+label,systname, 0);
    else if ( isGen ) Fill("DYAnalysis/Vars/Accee_"+label,systname, 1);
    else if ( isReco ) Fill("DYAnalysis/Vars/Accee_"+label,systname, 2); 

    return 0;
}