예제 #1
0
void TestCorrections(double rawPt, double rawEta, double rawPhi, double rawE, double JPTE, int NPV)
{
  gROOT->ProcessLine("#include <vector>");
  gSystem->Load("libFWCoreFWLite.so");
  FWLiteEnabler::enable();
  ////////////// Construct the JetCorrectorParameters objects ///////////////////////
  string L1Tag    = "../data/Jec11V0_L1Offset_AK5JPT.txt"; 
  string L1JPTTag = "../data/Jec11V0_L1JPTOffset_AK5JPT.txt"; 
  JetCorrectorParameters *L1Par    = new JetCorrectorParameters(L1Tag);
  JetCorrectorParameters *L1JPTPar = new JetCorrectorParameters(L1JPTTag);
  vector<JetCorrectorParameters> vPar;
  vPar.push_back(*L1Par);
  vPar.push_back(*L1JPTPar);
  ////////////// Construct a FactorizedJetCorrector object //////////////////////
  FactorizedJetCorrector *JetCorrector = new FactorizedJetCorrector(vPar);
  ////////////// Loop over jets //////////////////////
  TLorentzVector rawJetP4(0);
  rawJetP4.SetPtEtaPhiE(rawPt,rawEta,rawPhi,rawE);
  JetCorrector->setJPTrawP4(rawJetP4); 
  JetCorrector->setJetE(JPTE);
  JetCorrector->setNPV(NPV);
  vector<float> vcor;
  vcor = JetCorrector->getSubCorrections();
  cout<<"Correction applied to JPT jet after L1Offset = "<<vcor[0]<<endl;
  cout<<"Correction applied to JPT jet after L1JPTOffset = "<<vcor[1]<<endl;
}
예제 #2
0
void testJetCorrectorParameters::compareBinIndex1D() {
    fX = {0.0};
    float eta=-9999;
    int oldBin=-1, newBin=-1;
    setupCorrector(false);

    cout << endl << "testJetCorrectorParameters::compareBinIndex1D" << endl;
    for(unsigned int ieta=0; ieta<veta.size()-1; ieta++) {
        loadbar3(ieta+1, veta.size()-1, 50, 10, "\tProgress:");
        eta = (veta[ieta]+veta[ieta+1])/2.0;
        fX = {eta};
        oldBin = L1JetPar->binIndex(fX);
        newBin = L1JetPar->binIndexN(fX);
        if((oldBin < 0 && newBin >= 0) || (oldBin >= 0 && newBin < 0)) {
            cout << "ERROR::testJetCorrectorParameters::compareBinIndex1D Unable to find the right bin for (eta)=(" << eta << ")" << endl
                 << "\t(oldBin,newBin)=(" << oldBin << "," << newBin << ")" << endl;
            CPPUNIT_ASSERT(oldBin >= 0 && newBin >= 0);
        }
        else if(oldBin!=newBin) {
            cout << "ERROR::testJetCorrectorParameters::compareBinIndex1D oldBin!=newBin (" << oldBin << "!=" << newBin << ") for (eta)=("
                 << eta << ")" << endl;
            CPPUNIT_ASSERT(oldBin==newBin);
        }

        jetCorrector->setJetEta(eta);
        jetCorrector->setRho(50.0);
        jetCorrector->setJetA(0.5);
        jetCorrector->setJetPt(100.0);
        CPPUNIT_ASSERT(jetCorrector->getCorrection()>=0);
    }
    destroyCorrector();
    cout << endl << "testJetCorrectorParameters::compareBinIndex1D All bins match between the linear and non-linear search algorithms for 1D files." << endl;
}
예제 #3
0
void testJetCorrectorParameters::compareBinIndex3D() {
    fX = {0.0,0.0,0.0};
    float eta=-9999, rho=-9999, pt=-9999;
    int oldBin=-1, newBin=-1;
    setupCorrector(true);

    cout << endl << "testJetCorrectorParameters::compareBinIndex3D" << endl;
    for(unsigned int ieta=0; ieta<veta.size()-1; ieta++) {
        for(unsigned int irho=0; irho<vrho.size()-1; irho++) {
            for(unsigned int ipt=0; ipt<vpt.size()-1; ipt++) {
                loadbar3(ieta*((vrho.size()-1)*(vpt.size()-1))+irho*(vpt.size()-1)+ipt+1,
                         (veta.size()-1)*(vrho.size()-1)*(vpt.size()-1), 50, 100, "\tProgress");
                eta = (veta[ieta]+veta[ieta+1])/2.0;
                rho = (vrho[irho]+vrho[irho+1])/2.0;
                pt = (vpt[ipt]+vpt[ipt+1])/2.0;
                fX = {eta,rho,pt};
                oldBin = L1JetPar->binIndex(fX);
                newBin = L1JetPar->binIndexN(fX);
                if((oldBin < 0 && newBin >= 0) || (oldBin >= 0 && newBin < 0)) {
                    cout << "ERROR::testJetCorrectorParameters::compareBinIndex3D Unable to find the right bin for (eta,rho,pt)=(" << eta << "," << rho << "," << pt << ")" << endl
                         << "\t(oldBin,newBin)=(" << oldBin << "," << newBin << ")" << endl;
                    CPPUNIT_ASSERT(oldBin >= 0 && newBin >= 0);
                }
                else if(oldBin!=newBin) {
                    cout << "ERROR::testJetCorrectorParameters::compareBinIndex3D oldBin!=newBin (" << oldBin << "!=" << newBin << ") for (eta,rho,pt)=("
                         << eta << "," << rho << "," << pt << ")" << endl;
                    CPPUNIT_ASSERT(oldBin==newBin);
                }

                jetCorrector->setJetEta(eta);
                jetCorrector->setRho(rho);
                jetCorrector->setJetA(0.5);
                jetCorrector->setJetPt(pt);
                CPPUNIT_ASSERT(jetCorrector->getCorrection()>=0);
            }
        }
    }
    destroyCorrector();
    cout << endl << "testJetCorrectorParameters::compareBinIndex3D All bins match between the linear and non-linear search algorithms for 3D files." << endl;
}
예제 #4
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;
}