Exemple #1
0
double unc( PseudoJet &iJet,JetCorrectionUncertainty *iJetUnc) { 
  if(fabs(iJet.eta()) > 5. || fabs(iJet.pt()) < 10.) return 1.;
  iJetUnc->setJetPt ( iJet.pt()  );
  iJetUnc->setJetEta( iJet.eta() );
  double jetunc = iJetUnc->getUncertainty(true);
  return jetunc;
}
PseudoJet FlavourKTPlugin::combine(const PseudoJet& jet1, const PseudoJet& jet2)
{
  PseudoJet newjet = PseudoJet(0., 0., 0., 0.);
  if (jet1.E() != 0. and jet2.E() != 0.) {
    newjet = jet1 + jet2;
  }
  addFlavour(newjet, combineFlavour(getFlavour(jet1), getFlavour(jet2)));
  return newjet;
}
Exemple #3
0
//vector<PseudoJet> threeHardest(vector<PseudoJet> &iParts, JetDefinition &iJetDef, Selector &iSelector,std::vector<ClusterSequence> &iCSs) {
// cluster full event (hard + pileup)
//  vector<PseudoJet> threehardest = iSelector(sorted_by_pt(cs.inclusive_jets()));
//  iCSs.push_back(cs);
//  return threehardest;
//}
PseudoJet match(PseudoJet &iJet,vector<PseudoJet> &iJets) {
    for(unsigned int i0 = 0; i0 < iJets.size(); i0++) {
        double pEta = fabs(iJet.eta()-iJets[i0].eta());
        double pPhi = fabs(iJet.phi() - iJets[i0].phi());
        if(pPhi > 2.*TMath::Pi()-pPhi) pPhi =  2.*TMath::Pi()-pPhi;
        if(sqrt(pEta*pEta+pPhi*pPhi) > 0.3) continue;
        return iJets[i0];
    }
    return PseudoJet();
}
Exemple #4
0
double correction( PseudoJet &iJet,FactorizedJetCorrector *iJetCorr,double iRho) { 
  iJetCorr->setJetPt (iJet.pt());
  iJetCorr->setJetEta(iJet.eta());
  iJetCorr->setJetPhi(iJet.phi());
  iJetCorr->setJetE  (iJet.e());
  iJetCorr->setJetA  (iJet.area());
  iJetCorr->setRho(iRho);
  iJetCorr->setJetEMF(-99.0);
  double jetcorr= iJetCorr->getCorrection();
  return jetcorr;
}
 void init(const PseudoJet& jet) {
   if (jet.E() == 0.) { // beam representative
     pt2 = 0.;
     rap = 0.;
     phi = 0.;
   } else {
     pt2 = jet.pt2();
     rap = jet.rapidity();
     phi = jet.phi();
   }
   lhid = FlavourKTPlugin::getFlavour(jet);
 }
Exemple #6
0
	float PhiLab( const PseudoJet& jet, Double_t PzInLepton, Double_t PzInHadron, TLorentzVector electron )
	{
		TLorentzVector p;
		p . SetPxPyPzE( jet.px(), jet.py(), jet.pz(), jet.e() );
		TObjArray InputCand;
		InputCand.Add( &p );
		
		TObjArray OutputCand;
		Dijets::BreitBoost( InputCand,  OutputCand, PzInLepton, PzInHadron, electron, 2 );
		OutputCand.SetOwner();
		float phi = (static_cast<TLorentzVector*>(OutputCand.At(0))) -> Phi();
		OutputCand.Clear();
		return phi;
	}
Vector2<Angle> PseudoJet::AnglesMinTo(PseudoJet const& jet) const
{
    auto angles = jet.Angles();
    auto angles_1 = Angles(false);
    auto angles_2 = Angles(true);
    return angles - angles_1 < angles - angles_2  ?  angles_1 : angles_2;
}
Exemple #8
0
void setJet(PseudoJet &iJet,JetInfo &iJetI,std::vector<PseudoJet> &iParticles, bool iCHS,FactorizedJetCorrector *iJetCorr,JetCorrectionUncertainty *iJetUnc,JetCleanser &gsn_cleanser) {
    vector<PseudoJet> neutrals,chargedLV,chargedPU;
    getConstitsForCleansing(iJet.constituents(),neutrals,chargedLV,chargedPU);
    PseudoJet     lClean = gsn_cleanser(neutrals,chargedLV,chargedPU);
    
    // define safeAreaSub (PF)
    AreaDefinition area_def(active_area_explicit_ghosts,GhostedAreaSpec(SelectorAbsRapMax(5.0)));
    JetDefinition jet_def_for_rho(kt_algorithm, 0.4);
    Selector rho_range =  SelectorAbsRapMax(5.0);
    ClusterSequenceArea clust_seq_rho(iParticles, jet_def_for_rho, area_def);
    // the two background estimators
    JetMedianBackgroundEstimator bge_rho (rho_range, clust_seq_rho);
    JetMedianBackgroundEstimator bge_rhom(rho_range, clust_seq_rho);
    BackgroundJetPtMDensity m_density;
    bge_rhom.set_jet_density_class(&m_density);
    
    // declare an area-median subtractor from this
    contrib::SafeAreaSubtractor *area_subtractor = 0;
    if(!iCHS) area_subtractor = new contrib::SafeAreaSubtractor(&bge_rho, &bge_rhom);
    if( iCHS) area_subtractor = new contrib::SafeAreaSubtractor(&bge_rho, &bge_rhom,SelectorIsPupCharged(),SelectorIsPupVertex());
    //iGMBE->set_particles(iParticles);
    PseudoJet lCorr =  (*area_subtractor)(iJet);
    fastjet::Filter trimmer( fastjet::Filter(fastjet::JetDefinition(fastjet::kt_algorithm, 0.2), fastjet::SelectorPtFractionMin(0.05)));
    PseudoJet lTrim     = (trimmer)(iJet);
    trimmer.set_subtractor(area_subtractor);
    PseudoJet lTrimSafe = (trimmer)(iJet);
    JetMedianBackgroundEstimator bge_rhoC(rho_range,jet_def_for_rho, area_def);
    BackgroundJetScalarPtDensity *scalarPtDensity = new BackgroundJetScalarPtDensity();
    bge_rhoC.set_jet_density_class(scalarPtDensity);
    bge_rhoC.set_particles(iParticles);
    contrib::ConstituentSubtractor subtractor(&bge_rhoC);
    subtractor.use_common_bge_for_rho_and_rhom(true);
    PseudoJet lConstit = subtractor(iJet);

    //Finally apply the JEC
    double lJEC = correction(iJet,iJetCorr,bge_rho.rho());  
    double lUnc = unc       (iJet,iJetUnc);
    iJetI.pt          = lCorr     .pt();
    iJetI.ptcorr      = iJet      .pt()*lJEC;
    iJetI.ptraw       = iJet      .pt();
    iJetI.ptclean     = lClean    .pt();
    iJetI.pttrim      = lTrim     .pt();
    iJetI.pttrimsafe  = lTrimSafe .pt();
    iJetI.ptconst     = lConstit  .pt();
    iJetI.ptunc       = lUnc;
    iJetI.eta         = iJet      .eta();
    iJetI.phi         = iJet      .phi();
    iJetI.mraw        = iJet      .m();
    iJetI.m           = lCorr     .m();
    iJetI.mclean      = lClean    .m();
    iJetI.mtrim       = lTrim     .m();
    iJetI.mtrimsafe   = lTrimSafe .m();
    iJetI.mconst      = lConstit  .m();
}
Angle PseudoJet::DeltaRapTo(PseudoJet const& jet) const
{
    return jet.Rap() - Rap();
}
int FlavourKTPlugin::getFlavour(const PseudoJet& jet)
{
  return jet.user_index();
}
void FlavourKTPlugin::addFlavour(PseudoJet& jet, int lhid)
{
//   FlavourInfo* finfo = new FlavourInfo(lhid);
//   jet.set_user_info(finfo);
  jet.set_user_index(lhid);
}
Exemple #12
0
 virtual bool pass(const PseudoJet & jet) const {
   return (jet.user_index() == 2);
 }
Exemple #13
0
int main (int argc, char ** argv) {
  //gROOT->ProcessLine("#include <vector>");          
  int maxEvents     = atoi(argv[1]);
  std::string lName = argv[2];
  bool        lGen  = atoi(argv[3]);
  //Setup JEC on the fly
  std::string cmsenv = "/afs/cern.ch/user/p/pharris/pharris/public/bacon/prod/CMSSW_6_2_7_patch2/src/";
  std::vector<JetCorrectorParameters> corrParams;
  corrParams.push_back(JetCorrectorParameters(cmsenv+"BaconProd/Utils/data/Summer13_V1_MC_L1FastJet_AK5PF.txt"));
  corrParams.push_back(JetCorrectorParameters(cmsenv+"BaconProd/Utils/data/Summer13_V1_MC_L2Relative_AK5PF.txt"));
  corrParams.push_back(JetCorrectorParameters(cmsenv+"BaconProd/Utils/data/Summer13_V1_MC_L3Absolute_AK5PF.txt"));
  //corrParams.push_back(JetCorrectorParameter(cmsenv+'BaconProd/Utils/data/Summer13_V1_DATA_L2L3Residual_AK5PF.txt'));
  JetCorrectorParameters     param(cmsenv+"BaconProd/Utils/data/Summer13_V1_DATA_Uncertainty_AK5PF.txt");
  FactorizedJetCorrector   *jetCorr = new FactorizedJetCorrector(corrParams);
  JetCorrectionUncertainty *jetUnc  = new JetCorrectionUncertainty(param);

  //Setup JetAlgos
  double R = 0.4;
  JetDefinition jet_def(antikt_algorithm,R);         // the jet definition....
  AreaDefinition area_def(active_area_explicit_ghosts,GhostedAreaSpec(SelectorAbsRapMax(5.0)));
  Selector selector = SelectorNHardest(3);   // definition of a selector for the three hardest jets
  //Now setup cleansing
  JetDefinition subjet_def(kt_algorithm,0.2);
  JetCleanser gsn_cleanser(subjet_def,JetCleanser::gaussian_cleansing,JetCleanser::input_nc_separate);
  gsn_cleanser.SetGaussianParameters(0.617,0.62,0.15,0.22);
  //Now read a file
  lName =  "root://eoscms.cern.ch//store/group/phys_jetmet/ntran/PUPPI/miniSamples/62x/rsgww1000_62x_PU40BX50/ntuple_1_1_VQC.root";
  lGen  = true;
  TTree *lTree = load(lName); 
  if(lTree->GetEntries() < maxEvents || maxEvents == -1) maxEvents = lTree->GetEntries(); 
  //Declare Readers
  //fEvt      = new EvtLoader     (lTree);
  fMuon     = new MuonLoader    (lTree);
  fPFCand   = new PFLoader      (lTree,"Puppi_cff.py");
  if(lGen) fGen      = new GenLoader     (lTree);

  TFile *lFile = new TFile("Output.root","RECREATE");
  TTree *lOut  = new TTree("Tree","Tree");
  //Setup Tree
  //fEvt    ->setupTree      (lOut);
  //fMuon   ->setupTree      (lOut);
  fPFCand ->setupTree      (lOut);
  //if(lGen) fGen ->setupTree      (lOut);
    
  int lIndex = 0; lOut->Branch("index",&lIndex,"lIndex/F");
  JetInfo JGen;     setupTree(lOut,JGen    ,"Gen"  );
  JetInfo JPF;      setupTree(lOut,JPF     ,"PF"   );
  JetInfo JPup;     setupTree(lOut,JPup    ,"Puppi");
  JetInfo JCHS;     setupTree(lOut,JCHS    ,"CHS"  );
  JetInfo JCHS2GeV; setupTree(lOut,JCHS2GeV,"CHS2GeV");
  JetInfo JSoft;    setupTree(lOut,JSoft   ,"SK"  );
  JetInfo JSoftCHS; setupTree(lOut,JSoftCHS,"SKCHS");

  for(int i0 = 0; i0 < maxEvents; i0++) { 
    //if(i0 < 108) continue;
    if(i0 % 2 == 0) std::cout << "===> Processed " << i0 << " - Done : " << (float(i0)/float(maxEvents)) << std::endl;
    clear(JGen);
    clear(JPF);
    clear(JPup);
    clear(JCHS);
    clear(JCHS2GeV);
    
    //////////////////////////////////////////////////////
    fPFCand->load(i0);
    fGen   ->load(i0); 
    vector<PseudoJet> gen_event       = fGen   ->genFetch();
    vector<PseudoJet> puppi_event     = fPFCand->puppiFetch();
    vector<PseudoJet> pf_event        = fPFCand->pfFetch();
    vector<PseudoJet> chs_event       = fPFCand->pfchsFetch(-1);
    vector<PseudoJet> chs_event2GeV   = fPFCand->pfchsFetch( 2.);
    //////////////////////////////////////////////////////
    SoftKiller soft_killer   (0.4,0.4);
    SoftKiller soft_killerCHS(4.0,0.5, !SelectorIsPupCharged());
    vector<PseudoJet> soft_event    = soft_killer   (pf_event);
    vector<PseudoJet> softCHS_event = soft_killerCHS(chs_event);
    
    ClusterSequenceArea pGen    (gen_event    ,jet_def,area_def);
    ClusterSequenceArea pPup    (puppi_event  ,jet_def,area_def);
    ClusterSequenceArea pPF     (pf_event     ,jet_def,area_def);
    ClusterSequenceArea pCHS    (chs_event    ,jet_def,area_def);
    ClusterSequenceArea pCHS2GeV(chs_event2GeV,jet_def,area_def);
    ClusterSequenceArea pSoft   (soft_event   ,jet_def,area_def);
    ClusterSequenceArea pSoftCHS(softCHS_event,jet_def,area_def);
    vector<PseudoJet> genJets     = selector(sorted_by_pt(pGen    .inclusive_jets()));
    vector<PseudoJet> puppiJets   = selector(sorted_by_pt(pPup    .inclusive_jets()));
    vector<PseudoJet> pfJets      = selector(sorted_by_pt(pPF     .inclusive_jets()));
    vector<PseudoJet> chsJets     = selector(sorted_by_pt(pCHS    .inclusive_jets()));
    vector<PseudoJet> chs2GeVJets = selector(sorted_by_pt(pCHS2GeV.inclusive_jets()));
    vector<PseudoJet> softJets    = selector(sorted_by_pt(pSoft   .inclusive_jets()));
    vector<PseudoJet> softCHSJets = selector(sorted_by_pt(pSoftCHS.inclusive_jets()));
    for(unsigned int i0 = 0; i0 < genJets.size(); i0++) {
      lIndex = i0;
      PseudoJet puppiJet   = match(genJets[i0],puppiJets);
      PseudoJet pfJet      = match(genJets[i0],pfJets   );
      PseudoJet chsJet     = match(genJets[i0],chsJets  );
      PseudoJet chs2GeVJet = match(genJets[i0],chs2GeVJets);
      PseudoJet softJet    = match(genJets[i0],softJets);
      PseudoJet softCHSJet = match(genJets[i0],softCHSJets);
      setJet(genJets[i0],JGen    ,gen_event   ,false,jetCorr,jetUnc,gsn_cleanser);
      if(pfJet.pt()      != 0) setJet(pfJet ,     JPF     ,pf_event     ,false,jetCorr,jetUnc,gsn_cleanser);
      if(chsJet.pt()     != 0) setJet(chsJet,     JCHS    ,chs_event    ,true ,jetCorr,jetUnc,gsn_cleanser);
      if(chs2GeVJet.pt() != 0) setJet(chs2GeVJet, JCHS2GeV,chs_event2GeV,true ,jetCorr,jetUnc,gsn_cleanser);
      if(puppiJet.pt()   != 0) setJet(puppiJet  , JPup    ,puppi_event  ,true ,jetCorr,jetUnc,gsn_cleanser);
      if(softJet.pt()    != 0) setJet(softJet   , JSoft   ,soft_event   ,false,jetCorr,jetUnc,gsn_cleanser);
      if(softCHSJet.pt() != 0) setJet(softCHSJet, JSoftCHS,softCHS_event,true ,jetCorr,jetUnc,gsn_cleanser);
      lOut->Fill();
    }
  }
  lFile->cd();
  lOut->Write();
}