示例#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;
}
示例#2
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;
}
示例#3
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();
}