Esempio n. 1
0
void ChPartTree::GetEvtId(const edm::Event& iEvent)
{
   using namespace std;

   if ( EvtIdDebug )
   {
     cout << "XJ: EvdId: " << iEvent.id() << endl ;
     cout << "XJ: Run  : " << iEvent.id().run() << endl ;
     cout << "XJ: Evt  : " << iEvent.id().event() << endl ;
     cout << "XJ: Lumbl: " << iEvent.luminosityBlock() << endl ;
//   cout << "XJ: proID: " << iEvent.processHistoryID() << endl;
//   cout << "XJ: GUID : " << iEvent.processGUID() << endl;
     edm::Timestamp Time=iEvent.time();
     cout << "XJ: time : " << Time.value() << endl;
     cout << "XJ: isDa : " << iEvent.isRealData() << endl;
     cout << "XJ: expTy: " << iEvent.experimentType() << endl ;
     cout << "XJ: Bx   : " << iEvent.bunchCrossing() << endl;
     cout << "XJ: Orbit: " << iEvent.orbitNumber() << endl;
//   cout << "XJ: Store: " << iEvent.storeNumber() << endl; 
   }

   EvtId.Reset();

   EvtId.Run       = iEvent.id().run() ;   
   EvtId.Evt       = iEvent.id().event() ;
   EvtId.LumiSect  = iEvent.luminosityBlock();
   edm::Timestamp Time=iEvent.time();
   EvtId.Time      = Time.value(); 
   EvtId.IsData    = iEvent.isRealData();
   EvtId.ExpType   = iEvent.experimentType();
   EvtId.Bunch     = iEvent.bunchCrossing();
   EvtId.Orbit     = iEvent.orbitNumber();

}
Esempio n. 2
0
int NeroAll::analyze(const edm::Event&iEvent)
{
    if(isMc_ <0 )
    {
        isMc_ = ( iEvent.isRealData() ) ? 0 : 1;
        isRealData = ( iEvent.isRealData() ) ? 1 : 0;
    }
    if( isSkim() == 0) 
    {
        //TODO FILL all_
        isRealData = ( iEvent.isRealData() ) ? 1 : 0;	
        runNum = iEvent.id().run();
        lumiNum = iEvent.luminosityBlock(); 	
        eventNum = iEvent.id().event();  
        iEvent.getByLabel(edm::InputTag("generator"), info_handle); // USE TOKEN AND INPUT TAG ?
        iEvent.getByLabel(edm::InputTag("addPileupInfo"), pu_handle);
        mcWeight = info_handle->weight();
        //PU
        puTrueInt = 0;
        for(const auto & pu : *pu_handle)
        {
            //Intime
            if (pu.getBunchCrossing() == 0)
                puTrueInt += pu.getTrueNumInteractions();
            //Out-of-time
        }
    }
    return 0;
}
Esempio n. 3
0
int NeroMonteCarlo::analyze(const edm::Event& iEvent){

    if ( iEvent.isRealData() ) return 0;
    isRealData = iEvent.isRealData() ? 1 : 0 ; // private, not the one in the tree

    TStopwatch sw;
    if(VERBOSE)sw.Start();
    // maybe handle should be taken before
    iEvent.getByToken(info_token, info_handle);
    iEvent.getByToken(packed_token, packed_handle);
    iEvent.getByToken(pruned_token, pruned_handle);
    iEvent.getByToken(pu_token, pu_handle);
    iEvent.getByToken(jet_token, jet_handle);

    if ( not info_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] info_handle is not valid"<<endl;
    if ( not packed_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] packed_handle is not valid"<<endl;
    if ( not pruned_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] pruned_handle is not valid"<<endl;
    if ( not pu_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] pu_handle is not valid"<<endl;
    if ( not jet_handle.isValid() ) cout<<"[NeroMonteCarlo]::[analyze]::[ERROR] jet_handle is not valid"<<endl;

    if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] getToken took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset(); sw.Start();}
    // INFO
    if(VERBOSE>1) cout<<"[NeroMonteCarlo]::[analyze]::[DEBUG] mcWeight="<<endl;
    mcWeight = info_handle -> weight();
    if(VERBOSE>1) cout<<"                                     mcWeight="<<mcWeight<<endl;
    //weights() 
    //---  scale
    if ( info_handle -> weights()  .size() >= 9){
        r1f2 = info_handle -> weights() [1] ;   
        r1f5 = info_handle -> weights() [2] ;   
        r2f1 = info_handle -> weights() [3] ;   
        r2f2 = info_handle -> weights() [4] ;   
        r5f1 = info_handle -> weights() [6] ;    
        r5f5 = info_handle -> weights() [8] ;     
    }

    if (info_handle -> weights().size() > 109)
        for( int pdfw = 9 ; pdfw<109 ;++pdfw)
        {
        pdfRwgt -> push_back( info_handle -> weights() [pdfw] );    
        }
    // --- fill pdf Weights
    //
    if(VERBOSE>1) cout<<"[NeroMonteCarlo]::[analyze]::[DEBUG] PDF="<<endl;
    if ( mParticleGun ) {
        qScale   = -999 ;
        alphaQED = -999 ;
        alphaQCD = -999 ;
        x1       = -999 ;
        x2       = -999 ;
        pdf1Id   = -999 ;
        pdf2Id   = -999 ;
        scalePdf = -999 ;
    }
    else {
        qScale   = info_handle -> qScale();
        alphaQED = info_handle -> alphaQED();
        alphaQCD = info_handle -> alphaQCD();
        x1       = info_handle -> pdf() -> x.first;
        x2       = info_handle -> pdf() -> x.second;
        pdf1Id   = info_handle -> pdf() -> id.first;
        pdf2Id   = info_handle -> pdf() -> id.second;
        scalePdf = info_handle -> pdf() -> scalePDF;
    }
    if(VERBOSE>1) cout<<"                                     PDF="<<qScale<<" "<< alphaQED<<endl;

    //PU
    if(VERBOSE>1){ cout<<endl<<"[NeroMonteCarlo]::[analyze] PU LOOP"<<endl;}
    puTrueInt = 0;
    for(const auto & pu : *pu_handle)
    {
        //Intime
        if (pu.getBunchCrossing() == 0)
            puTrueInt += pu.getTrueNumInteractions();
        //puInt += getPU_NumInteractions(); //old
        //Out-of-time
    }

    if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] pu&info took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset(); sw.Start();}
    // GEN PARTICLES
    //TLorentzVector genmet(0,0,0,0);
    //for ( auto & gen : *packed_handle)
    for ( unsigned int i=0;i < packed_handle->size() ;++i)
    {
        const auto gen  = & (*packed_handle)[i];
        if (gen->pt()  < 5 ) continue;
        if (gen->pt() < mMinGenParticlePt ) continue;
        int pdg = gen->pdgId();
        int apdg = abs(pdg);

        //neutrinos
        // --- if ( (apdg != 12 and apdg !=14 and apdg != 16
        // ---       and apdg > 1000000  neutrinos and neutralinos
        // ---      )//SUSY
        // ---         and fabs(gen->eta() ) <4.7 
        // ---    )
        // --- { 
        // ---     TLorentzVector tmp( gen->px(),gen->py(),gen->pz(),gen->energy() ); 
        // ---     genmet += tmp;
        // --- }
        // --- genmet = -genmet;


        //FILL
        //    e mu photons
        if ( apdg == 11 or apdg == 13 or apdg == 22  // e - mu - gamma
                or (apdg >=12 and apdg<=16) // neutrinos
                or apdg > 1000000  // susy neutrinos and neutralinos
            )
        {
            new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(gen->px(), gen->py(), gen->pz(), gen->energy());
            pdgId -> push_back( pdg );
            flags -> push_back( ComputeFlags( *gen ) );
            // compute ISOLATION
            float iso=0;
            float isoFx=0;

            if (apdg == 22 or apdg ==11 or apdg ==13)
            {

                    TLorentzVector g1(gen->px(),gen->py(),gen->pz(),gen->energy());
                    vector< pair<float,float> > inIsoFx ; //isoFx, dR, pT
                    for ( unsigned int j=0;j < packed_handle->size() ;++j)
                    {
                        if (i==j) continue;
                        const auto gen2  = & (*packed_handle)[j];
                        if ( gen2->pt() ==0 ) continue;
                        if (gen2->pz() > 10e8 ) continue; // inf
                        TLorentzVector g2(gen2->px(),gen2->py(),gen2->pz(),gen2->energy());
                        if (g2.DeltaR(g1) <0.4){
                            iso += g2.Pt();
                            // isoFx containes the epsilon 
                            inIsoFx.push_back( pair<float,float>(g2.DeltaR(g1) ,g2.Pt() ) );
                         }
                    }

                    if (apdg==22){ // ONLY for photon Frixione isolation
                        sort(inIsoFx.begin(), inIsoFx.end() );  // sort in DR, first entry

                        float sumEtFx=0;
                        for( const auto & p : inIsoFx )
                        {
                               const float& pt= p.second ;
                               const float& delta = p.first;
                               sumEtFx += pt / gen->pt(); // relative iso
                               if (delta == 0 ) continue; // guard
                               float isoCandidate = sumEtFx * TMath::Power(  (1. - TMath::Cos(0.4) ) / (1. - TMath::Cos(delta ) ), 2) ;// n=2
                               if (isoFx < isoCandidate) isoFx = isoCandidate;
                        }
                    }
            
            }
            genIso -> push_back(iso);
            genIsoFrixione -> push_back(isoFx);
            // computed dressed objects
            //

            if (apdg == 11 or apdg == 13) { // only for final state muons and electrons
                    TLorentzVector dressedLepton(gen->px(),gen->py(),gen->pz(),gen->energy());
                    TLorentzVector lepton(dressedLepton); //original lepton for dR
                    for ( unsigned int j=0;j < packed_handle->size() ;++j)
                    {
                        const auto gen2  = & (*packed_handle)[j];
                        TLorentzVector photon(gen2->px(),gen2->py(),gen2->pz(),gen2->energy());
                        if (i != j and abs( gen->pdgId() ) ==22  and lepton.DeltaR( photon ) <0.1 ) dressedLepton += photon;
                    }
                    new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector( dressedLepton );
                    pdgId -> push_back( pdg );
                    flags -> push_back( Dressed );
                    genIso -> push_back (0.) ;
                    genIsoFrixione -> push_back (0.) ;
                    // --- end of dressing
            }
             
        }

    } //end packed


    if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] packed took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset(); sw.Start();}
    // LOOP over PRUNED PARTICLES
    //for (auto & gen : *pruned_handle)
    for (unsigned int i=0;i<pruned_handle->size() ;++i)
    {
        const auto gen = &(*pruned_handle)[i];
        if (gen->pt()  < 5 ) continue;
        if (gen->pt()  < mMinGenParticlePt ) continue;
        int pdg = gen->pdgId();
        int apdg = abs(pdg);
        if (gen->status() == 1) continue; //packed

        unsigned flag = ComputeFlags(*gen);

    
        if ( apdg == 15 or  // tau (15)
                (apdg >= 23 and apdg <26 ) or   // Z(23) W(24) H(25)
                apdg == 37 or // chHiggs: H+(37)
                apdg <= 6 or // quarks up (2) down (1)  charm (4) strange (3) top (6) bottom (5)
                apdg == 21 or // gluons (21)
                apdg > 1000000 // susy neutrinos,neutralinos, charginos ...  lightest neutralinos (1000022)
                or ( apdg == 11 and  ( flag &  HardProcessBeforeFSR) )
                or ( apdg == 11 and  ( flag &  HardProcess) )
                or ( apdg == 13 and  ( flag &  HardProcessBeforeFSR) )
                or ( apdg == 13 and  ( flag &  HardProcess) )
                )
        {
            new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(gen->px(), gen->py(), gen->pz(), gen->energy());
            pdgId -> push_back( pdg );
            flags -> push_back( flag );
            genIso -> push_back (0.) ;
            genIsoFrixione -> push_back (0.) ;
        }
    }

    if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] pruned took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset(); sw.Start();}
    // GEN JETS
    for (const auto & j : *jet_handle)
    {
        if (j.pt() < 20 ) continue;
        if (j.pt() < mMinGenJetPt ) continue;
        // --- FILL
        new ( (*jetP4)[jetP4->GetEntriesFast()]) TLorentzVector(j.px(), j.py(), j.pz(), j.energy());
    }
    if(VERBOSE){ sw.Stop() ; cout<<"[NeroMonteCarlo]::[analyze] jets took "<<sw.CpuTime()<<" Cpu and "<<sw.RealTime()<<" RealTime"<<endl; sw.Reset();}
    return 0;
}
Esempio n. 4
0
int NeroMet::analyze(const edm::Event& iEvent){

    if ( mOnlyMc  ) return 0; // in principle I would like to have the gen met: TODO

    // maybe handle should be taken before
    iEvent.getByToken(token, handle);
    const pat::MET &met = handle->front();

    // FILL
    new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector( met.px(),met.py(),met.pz(),met.energy()  );

    ptJESUP -> push_back( met.shiftedPt(pat::MET::JetEnUp) );
    ptJESDOWN -> push_back( met.shiftedPt(pat::MET::JetEnDown) );


    if (IsExtend())
    {
        //MetNoMu
        TLorentzVector metnomu(met.px(),met.py(),met.pz(),met.energy());
        TLorentzVector pfmet_e3p0(0,0,0,0);
        TLorentzVector chMet(0,0,0,0); 
        TLorentzVector nhMet(0,0,0,0); 
        TLorentzVector phoMet(0,0,0,0); 
        
    
        if ( pf == NULL ) cout<<"[NeroMet]::[analyze]::[ERROR] PF pointer is null. Run NeroPF. "<<endl; 
        
        for (unsigned int i = 0, n = pf->handle->size(); i < n; ++i) {
            const pat::PackedCandidate &cand = (*pf->handle)[i];
            
            // only up to eta 3
            if (std::abs(cand.eta()) < 3.0)
                pfmet_e3p0 += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy());
            
            if (std::abs(cand.pdgId()) == 13)
                metnomu += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy());  
            
            // only charge hadrons
            if ( cand.charge() != 0 and cand.pdgId() > 20 )
                chMet += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy());
            if ( cand.charge() == 0 and cand.pdgId() == 22 ) 
                phoMet += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy());
            if ( cand.charge() == 0 and cand.pdgId() != 22 ) 
                nhMet += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy());
        }
        
        *metNoMu = TLorentzVector(metnomu);    
        *metChargedHadron = TLorentzVector(chMet);
        *metNeutralHadron = TLorentzVector(nhMet);
        *metNeutralEM = TLorentzVector(phoMet);
        *pfMet_e3p0 = TLorentzVector(pfmet_e3p0);
    
    }    
    // GEN INFO
    if ( not iEvent.isRealData () ){
        new ( (*genP4)[genP4->GetEntriesFast()]) TLorentzVector( met.genMET()->px(),met.genMET()->py(),met.genMET()->pz(),met.genMET()->energy()  );
    }


    return 0;
}
Esempio n. 5
0
int NeroMetRecluster::analyze(const edm::Event& iEvent){

    if ( mOnlyMc  ) return 0; // in principle I would like to have the gen met: TODO

    // maybe handle should be taken before
    iEvent.getByToken(token, handle);
    if ( not handle.isValid() ) cout<<"[NeroMetRecluster]::[analyze]::[ERROR] handle is not valid"<<endl;

    iEvent.getByToken(token_puppi,handle_puppi);
    if ( not handle_puppi.isValid() ) cout<<"[NeroMetRecluster]::[analyze]::[ERROR] handle_puppi is not valid"<<endl;

    iEvent.getByToken(token_puppiUncorr,handle_puppiUncorr);
    if ( not handle_puppiUncorr.isValid() ) cout<<"[NeroMetRecluster]::[analyze]::[ERROR] handle_puppiUncorr is not valid"<<endl;
    //--

    const pat::MET &met = handle->front();

    caloMet_Pt = met.caloMETPt();
    caloMet_Phi = met.caloMETPhi();
    caloMet_SumEt = met.caloMETSumEt();


    // FILL
    new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector( met.px(),met.py(),met.pz(),met.energy()  );

    sumEtRaw = met.uncorSumEt();

    ptJESUP -> push_back( met.shiftedPt(pat::MET::JetEnUp) );
    ptJESDOWN -> push_back( met.shiftedPt(pat::MET::JetEnDown) );

    rawMet_Pt = met.uncorPt(); 
    rawMet_Phi = met.uncorPhi();


    if (IsExtend())
    {
        //MetNoMu
        TLorentzVector metnomu(met.px(),met.py(),met.pz(),met.energy());
        TLorentzVector tkMet(0,0,0,0); 
        TLorentzVector pfmet_3p0(0,0,0,0); 

        if ( pf == NULL ) cout<<"[NeroMetRecluster]::[analyze]::[ERROR] PF pointer is null. Run NeroPF. "<<endl; 

        for (unsigned int i = 0, n = pf->handle->size(); i < n; ++i) {
            const pat::PackedCandidate &cand = (*pf->handle)[i];

            // only up to eta 3
            if (std::abs(cand.pdgId()) == 13)
                metnomu += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy());  

            // only charge hadrons
            if ( cand.charge() != 0 )
                tkMet += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy());

            if (std::abs(cand.eta()) < 3.0 ) 
                pfmet_3p0 += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy());
        }

        *pfMet_e3p0 = TLorentzVector( -pfmet_3p0 );
        *metNoMu = TLorentzVector(metnomu);  // no minus
        *trackMet = TLorentzVector( -tkMet );

        auto &puppi = handle_puppi->front(); 
        *metPuppi =  TLorentzVector( puppi.px(), puppi.py(),puppi.pz(),puppi.energy() );
        sumEtRawPuppi = handle_puppiUncorr->front().sumEt();

    }    
    // GEN INFO
    if ( not iEvent.isRealData () ){
        new ( (*genP4)[genP4->GetEntriesFast()]) TLorentzVector( met.genMET()->px(),met.genMET()->py(),met.genMET()->pz(),met.genMET()->energy()  );
    }


    return 0;
}
Esempio n. 6
0
int NeroPuppiFatJets::analyze(const edm::Event& iEvent)
{

    if ( mOnlyMc  ) return 0;

    if ( mMinId == "none" ) return 0;

    // maybe handle should be taken before
    iEvent.getByToken(token, handle);
    iEvent.getByToken(rho_token,rho_handle);
    
    TString tPrefix(cachedPrefix);

    edm::Handle<reco::PFJetCollection> subjets_handle;
    edm::InputTag subjetLabel("PFJetsSoftDrop"+tPrefix,"SubJets");
    //iEvent.getByLabel(subjetLabel,subjets_handle);
    iEvent.getByToken(subjets_token,subjets_handle);
    const reco::PFJetCollection *subjetCol = subjets_handle.product();
    assert(subjets_handle.isValid());

    edm::Handle<reco::JetTagCollection> btags_handle;
    //iEvent.getByLabel(edm::InputTag((tPrefix+"PFCombinedInclusiveSecondaryVertexV2BJetTags").Data()),btags_handle);
    iEvent.getByToken(btags_token,btags_handle);
    assert((btags_handle.isValid()));

    FactorizedJetCorrector *corrector = ( iEvent.isRealData() ) ? mDataJetCorrector : mMCJetCorrector;

    int ijetRef = -1;
    int nsubjet = 0;
    
          
    for (const pat::Jet& j : *handle)
    {
        ijetRef++;

        if (fabs(j.eta() ) > mMaxEta)  continue; 
        if ( !NeroPuppiJets::JetId(j,mMinId) ) continue;
        // pT cut applied after applying JEC if necessary

        // GET  ValueMaps

        // Fill output object   

          // this was reclustered from mini AOD, so we have to apply JEC, etc

          edm::RefToBase<pat::Jet> jetRef(edm::Ref<pat::JetCollection>(handle,ijetRef));

          double jecFactor=0;
          if (fabs(j.eta())<5.191) {
            corrector->setJetPt(j.pt());
            corrector->setJetEta(j.eta());
            corrector->setJetPhi(j.phi());
            corrector->setJetE(j.energy());
            corrector->setRho(*rho_handle);
            corrector->setJetA(j.jetArea());
            corrector->setJetEMF(-99.0);
            jecFactor = corrector->getCorrection();
          }

          if (j.pt()*jecFactor < mMinPt)  continue;
          rawPt -> push_back (j.pt());
          new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector(j.px()*jecFactor, j.py()*jecFactor, j.pz()*jecFactor, j.energy()*jecFactor);

          tau1 -> push_back(j.userFloat(tPrefix+"Njettiness:tau1"));
          tau2 -> push_back(j.userFloat(tPrefix+"Njettiness:tau2"));
          tau3 -> push_back(j.userFloat(tPrefix+"Njettiness:tau3"));
  
          softdropMass->push_back(j.userFloat(tPrefix+"SDKinematics:Mass")*jecFactor);
    
          unsigned int nsubjetThisJet=0;
          firstSubjet->push_back(nsubjet);

          for (reco::PFJetCollection::const_iterator i = subjetCol->begin(); i!=subjetCol->end(); ++i) {
            if (reco::deltaR(i->eta(),i->phi(),j.eta(),j.phi())>jetRadius) continue;
            nsubjetThisJet++;
           
            new ( (*subjet)[nsubjet]) TLorentzVector(i->px(), i->py(), i->pz(), i->energy());
            nsubjet++;

            reco::JetBaseRef sjBaseRef(reco::PFJetRef(subjets_handle,i-subjetCol->begin()));
            subjet_btag->push_back((float)(*(btags_handle.product()))[sjBaseRef]);
          }

          nSubjets->push_back(nsubjetThisJet);

    }
    return 0;
}
Esempio n. 7
0
int NeroMet::analyze(const edm::Event& iEvent){

    if ( mOnlyMc  ) return 0; // in principle I would like to have the gen met: TODO

    // maybe handle should be taken before
    iEvent.getByToken(token, handle);
    if ( not handle.isValid() ) cout<<"[NeroMet]::[analyze]::[ERROR] handle is not valid"<<endl;

    if (rerunPuppi) {
        iEvent.getByToken(token_puppiRerun,handle_puppiRerun);
        if ( not handle_puppiRerun.isValid() ) cout<<"[NeroMetRecluster]::[analyze]::[ERROR] handle_puppiRerun is not valid"<<endl;

        iEvent.getByToken(token_puppiRerunUncorr,handle_puppiRerunUncorr);
        if ( not handle_puppiRerunUncorr.isValid() ) cout<<"[NeroMetRecluster]::[analyze]::[ERROR] handle_puppiRerunUncorr is not valid"<<endl;
    } else {
        iEvent.getByToken(token_puppi,handle_puppi);
        if ( not handle_puppi.isValid() ) cout<<"[NeroMet]::[analyze]::[ERROR] handle_puppi is not valid"<<endl;
    }


    // -- iEvent.getByToken(token_puppiUncorr,handle_puppiUncorr);
    // -- if ( not handle_puppiUncorr.isValid() ) cout<<"[NeroMet]::[analyze]::[ERROR] handle_puppiUncorr is not valid"<<endl;
    //--

    const pat::MET &met = handle->front();

    caloMet_Pt = met.caloMETPt();
    caloMet_Phi = met.caloMETPhi();
    caloMet_SumEt = met.caloMETSumEt();


    // FILL
    new ( (*p4)[p4->GetEntriesFast()]) TLorentzVector( met.px(),met.py(),met.pz(),met.energy()  );

    sumEtRaw = met.uncorSumEt();

    ptJESUP -> push_back( met.shiftedPt(pat::MET::JetEnUp) );
    ptJESDOWN -> push_back( met.shiftedPt(pat::MET::JetEnDown) );

    rawMet_Pt = met.uncorPt(); 
    rawMet_Phi = met.uncorPhi();


    if (IsExtend())
    {
        //MetNoMu
        TLorentzVector metnomu(met.px(),met.py(),met.pz(),met.energy());
        TLorentzVector tkMet(0,0,0,0); 
        TLorentzVector pfmet_3p0(0,0,0,0); 

        if ( pf == NULL ) cout<<"[NeroMet]::[analyze]::[ERROR] PF pointer is null. Run NeroPF. "<<endl; 

        for (unsigned int i = 0, n = pf->handle->size(); i < n; ++i) {
            const pat::PackedCandidate &cand = (*pf->handle)[i];

            // only up to eta 3
            if (std::abs(cand.pdgId()) == 13)
                metnomu += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy());  

            // only charge hadrons
            if ( cand.charge() != 0 )
                tkMet += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy());

            if (std::abs(cand.eta()) < 3.0 ) 
                pfmet_3p0 += TLorentzVector(cand.px(),cand.py(),cand.pz(),cand.energy());
        }
        

        *pfMet_e3p0 = TLorentzVector( -pfmet_3p0 );
        *metNoMu = TLorentzVector(metnomu);  // no minus
        *trackMet = TLorentzVector( -tkMet );

        if (rerunPuppi) {
            auto &puppi = handle_puppiRerun->front(); 
            *metPuppi =  TLorentzVector( puppi.px(), puppi.py(),puppi.pz(),puppi.energy() );
            sumEtRawPuppi = handle_puppiRerunUncorr->front().sumEt();
        } else {
            auto &puppi = handle_puppi->front(); 
            *metPuppi =  TLorentzVector( puppi.px(), puppi.py(),puppi.pz(),puppi.energy() );
            //sumEtRawPuppi = handle_puppiUncorr->front().sumEt();
            sumEtRawPuppi = puppi.uncorSumEt();
        }

        for(Syst mysyst = (Syst)0; mysyst < MaxSyst ; mysyst = (Syst)((int)mysyst +1 ) )
        {
            pat::MET::METUncertainty miniAODUnc=pat::MET::METUncertaintySize;
            // JetResUp=0, JetResDown=1, JetEnUp=2, JetEnDown=3,
            // MuonEnUp=4, MuonEnDown=5, ElectronEnUp=6, ElectronEnDown=7,
            // TauEnUp=8, TauEnDown=9, UnclusteredEnUp=10, UnclusteredEnDown=11,
            // PhotonEnUp=12, PhotonEnDown=13, NoShift=14, METUncertaintySize=15,
            // JetResUpSmear=16, JetResDownSmear=17, METFullUncertaintySize=18
            // translate
            switch (mysyst)
            {
                case  JesUp : {miniAODUnc = pat::MET::JetEnUp; break;}
                case  JesDown : {miniAODUnc = pat::MET::JetEnDown; break;}
                case  JerUp : {miniAODUnc = pat::MET::JetResUp; break;}
                case  JerDown : {miniAODUnc = pat::MET::JetResDown; break;}
                case  UnclusterUp : {miniAODUnc = pat::MET::UnclusteredEnUp; break;}
                case  UnclusterDown : {miniAODUnc = pat::MET::UnclusteredEnDown; break;}
                case  TauUp : {miniAODUnc = pat::MET::TauEnUp; break;}
                case  TauDown : {miniAODUnc = pat::MET::TauEnDown; break;}
                case  PhotonUp : {miniAODUnc = pat::MET::PhotonEnDown; break;}
                case  PhotonDown : {miniAODUnc = pat::MET::PhotonEnDown; break;}
                case  ElectronUp : {miniAODUnc = pat::MET::ElectronEnUp; break;}
                case  ElectronDown : {miniAODUnc = pat::MET::ElectronEnDown; break;}
                case  MuonUp : {miniAODUnc = pat::MET::MuonEnUp; break;}
                case  MuonDown : {miniAODUnc = pat::MET::MuonEnDown; break;}
                default : break;
            }

            if (miniAODUnc == pat::MET::METUncertaintySize)
                cout <<"[NeroMet]::[analyze]::[WARNING] unable to translate met syst,"<< int(mysyst) <<endl;

            /*
            new ( (*metPuppiSyst)[ mysyst ] ) TLorentzVector( 
                    puppi . shiftedP4( miniAODUnc).px(), 
                    puppi . shiftedP4(miniAODUnc).py(),  
                    puppi . shiftedP4(miniAODUnc).pz(),  
                    puppi . shiftedP4(miniAODUnc).energy()
                    );
            */

            new ( (*metSyst)[ mysyst ] ) TLorentzVector( 
                    met . shiftedP4( miniAODUnc).px(), 
                    met . shiftedP4(miniAODUnc).py(),  
                    met . shiftedP4(miniAODUnc).pz(),  
                    met . shiftedP4(miniAODUnc).energy()
                    );
        }// end syst loop
        

    }    
    // GEN INFO
    if ( not iEvent.isRealData () ){
        new ( (*genP4)[genP4->GetEntriesFast()]) TLorentzVector( met.genMET()->px(),met.genMET()->py(),met.genMET()->pz(),met.genMET()->energy()  );
    }


    return 0;
}