int main(int ac, char** av){ if(ac < 2){ std::cout << "usage: ./signalAcceptance inputFile[s]" << std::endl; return -1; } TH1F* allCategory = new TH1F("allCategory","all Category",19,0.5,19.5); allCategory->GetXaxis()->SetBinLabel(1,"Total"); allCategory->GetXaxis()->SetBinLabel(2,"AllHad"); allCategory->GetXaxis()->SetBinLabel(3,"1 lepton"); allCategory->GetXaxis()->SetBinLabel(4,"2 leptons"); allCategory->GetXaxis()->SetBinLabel(5,""); allCategory->GetXaxis()->SetBinLabel(6,"1 e"); allCategory->GetXaxis()->SetBinLabel(7,"2 e"); allCategory->GetXaxis()->SetBinLabel(8,"1 #mu"); allCategory->GetXaxis()->SetBinLabel(9,"2 #mu"); allCategory->GetXaxis()->SetBinLabel(10,"1 e 1 #mu"); allCategory->GetXaxis()->SetBinLabel(11,"1 e, 3 jets"); allCategory->GetXaxis()->SetBinLabel(12,"1 e, 3 jets 1 b"); allCategory->GetXaxis()->SetBinLabel(13,"1 e, 3 jets 1 b, MET"); allCategory->GetXaxis()->SetBinLabel(14,"1 e, 3 jets 1 b, MET, 1 pho"); allCategory->GetXaxis()->SetBinLabel(16,"1 #mu, 3 jets"); allCategory->GetXaxis()->SetBinLabel(17,"1 #mu, 3 jets 1 b"); allCategory->GetXaxis()->SetBinLabel(18,"1 #mu, 3 jets 1 b, MET"); allCategory->GetXaxis()->SetBinLabel(19,"1 #mu, 3 jets 1 b, MET, 1 pho"); TH1F* preselCategory = new TH1F("preselCategory","presel Category",19,0.5,19.5); preselCategory->GetXaxis()->SetBinLabel(1,"Total"); preselCategory->GetXaxis()->SetBinLabel(2,"AllHad"); preselCategory->GetXaxis()->SetBinLabel(3,"1 lepton"); preselCategory->GetXaxis()->SetBinLabel(4,"2 leptons"); preselCategory->GetXaxis()->SetBinLabel(5,""); preselCategory->GetXaxis()->SetBinLabel(6,"1 e"); preselCategory->GetXaxis()->SetBinLabel(7,"2 e"); preselCategory->GetXaxis()->SetBinLabel(8,"1 #mu"); preselCategory->GetXaxis()->SetBinLabel(9,"2 #mu"); preselCategory->GetXaxis()->SetBinLabel(10,"1 e 1 #mu"); preselCategory->GetXaxis()->SetBinLabel(11,"1 e, 3 jets"); preselCategory->GetXaxis()->SetBinLabel(12,"1 e, 3 jets 1 b"); preselCategory->GetXaxis()->SetBinLabel(13,"1 e, 3 jets 1 b, MET"); preselCategory->GetXaxis()->SetBinLabel(14,"1 e, 3 jets 1 b, MET, 1 pho"); preselCategory->GetXaxis()->SetBinLabel(16,"1 #mu, 3 jets"); preselCategory->GetXaxis()->SetBinLabel(17,"1 #mu, 3 jets 1 b"); preselCategory->GetXaxis()->SetBinLabel(18,"1 #mu, 3 jets 1 b, MET"); preselCategory->GetXaxis()->SetBinLabel(19,"1 #mu, 3 jets 1 b, MET, 1 pho"); TH1F* photonCategory = new TH1F("photonCategory","reco photon Category",19,0.5,19.5); photonCategory->GetXaxis()->SetBinLabel(1,"Total"); photonCategory->GetXaxis()->SetBinLabel(2,"AllHad"); photonCategory->GetXaxis()->SetBinLabel(3,"1 lepton"); photonCategory->GetXaxis()->SetBinLabel(4,"2 leptons"); photonCategory->GetXaxis()->SetBinLabel(5,""); photonCategory->GetXaxis()->SetBinLabel(6,"1 e"); photonCategory->GetXaxis()->SetBinLabel(7,"2 e"); photonCategory->GetXaxis()->SetBinLabel(8,"1 #mu"); photonCategory->GetXaxis()->SetBinLabel(9,"2 #mu"); photonCategory->GetXaxis()->SetBinLabel(10,"1 e 1 #mu"); photonCategory->GetXaxis()->SetBinLabel(11,"1 e, 3 jets"); photonCategory->GetXaxis()->SetBinLabel(12,"1 e, 3 jets 1 b"); photonCategory->GetXaxis()->SetBinLabel(13,"1 e, 3 jets 1 b, MET"); photonCategory->GetXaxis()->SetBinLabel(14,"1 e, 3 jets 1 b, MET, 1 pho"); photonCategory->GetXaxis()->SetBinLabel(16,"1 #mu, 3 jets"); photonCategory->GetXaxis()->SetBinLabel(17,"1 #mu, 3 jets 1 b"); photonCategory->GetXaxis()->SetBinLabel(18,"1 #mu, 3 jets 1 b, MET"); photonCategory->GetXaxis()->SetBinLabel(19,"1 #mu, 3 jets 1 b, MET, 1 pho"); TH1F* VisAllCategory = new TH1F("VisAllCategory","all Category, Vis",15,0.5,15.5); TH1F* VisPreselCategory = new TH1F("VisPreselCategory","presel Category, Vis",15,0.5,15.5); TH1F* VisPhotonCategory = new TH1F("VisPhotonCategory","reco photon Category, Vis",15,0.5,15.5); TH1F* dROtherGen = new TH1F("dROtherGen", "dROtherGen", 800, 0.0, 4.0); TH1F* parentage = new TH1F("parentage","parentage",30, 0, 30); TH1F* dptOverpt = new TH1F("dptOverpt","dptOverpt", 400, -2.0, 2.0); TH1F* dRrecoGen = new TH1F("dRrecoGen","dRrecoGen", 200, 0.0, 0.2); TH1F* dPhiRecoGen = new TH1F("dPhiRecoGen","dPhiRecoGen", 400, 0.0, 0.2); TH1F* dEtaRecoGen = new TH1F("dEtaRecoGen","dEtaRecoGen", 800, -0.2, 0.2); TH1F* dRGenNearJet = new TH1F("dRGenNearJet","dRGenNearJet", 200, 0.0, 1.0); TH1F* dPhiGenNearJet = new TH1F("dPhiGenNearJet","dPhiGenNearJet", 100, 0.0, 0.5); TH1F* dEtaGenNearJet = new TH1F("dEtaGenNearJet","dEtaGenNearJet", 200, -0.5, 0.5); //TH1F* dRGenNextNearJet = new TH1F("dRGenNextNearJet","dRGenNextNearJet", 600, 0.0, 6.0); //TH1F* dPhiGenNextNearJet = new TH1F("dPhiGenNextNearJet","dPhiGenNextNearJet", 300, 0.0, 3.0); //TH1F* dEtaGenNextNearJet = new TH1F("dEtaGenNextNearJet","dEtaGenNextNearJet", 600, -3.0, 3.0); // object selector Selector* selectorLoose = new Selector(); // create event selectors here EventPick* evtPickLoose = new EventPick("LoosePhotonID"); // do not do jet to photon dR cleaning evtPickLoose->veto_pho_jet_dR = 0.0; EventTree* tree = new EventTree(ac-1, av+1); double PUweight = 1.0; Long64_t nEntr = tree->GetEntries(); for(Long64_t entry=0; entry<nEntr; entry++){ if(entry%10000 == 0) std::cout << "processing entry " << entry << " out of " << nEntr << std::endl; tree->GetEntry(entry); doJER(tree); selectorLoose->process_objects(tree); evtPickLoose->process_event(tree, selectorLoose, PUweight); // fill the histograms fillCategory(tree, allCategory, PUweight); if(evtPickLoose->passPreSel) fillCategory(tree, preselCategory, PUweight); if(evtPickLoose->passAll) fillCategory(tree, photonCategory, PUweight); // fill histograms for gen photon passing the acceptance cuts defined in analysis bool inAcc = false; for(int mcInd=0; mcInd<tree->nMC_; ++mcInd){ if(tree->mcPID->at(mcInd) == 22 && (tree->mcParentage->at(mcInd)==2 || tree->mcParentage->at(mcInd)==10 || tree->mcParentage->at(mcInd)==26) && tree->mcPt->at(mcInd) > 25 && fabs(tree->mcEta->at(mcInd)) < 1.4442){ inAcc = true; } } if(inAcc){ fillCategory(tree, VisAllCategory, PUweight); if(evtPickLoose->passPreSel) fillCategory(tree, VisPreselCategory, PUweight); if(evtPickLoose->passAll) fillCategory(tree, VisPhotonCategory, PUweight); } // have at least one good photon if(!evtPickLoose->passAll) continue; // test //if(overlapMadGraph(tree)) continue; int phoInd = evtPickLoose->Photons.at(0); // experiment with delta R cuts for photons for(int mcInd=0; mcInd<tree->nMC_; ++mcInd){ bool etetamatch = dR(tree->mcEta->at(mcInd),tree->mcPhi->at(mcInd),tree->phoEta_->at(phoInd),tree->phoPhi_->at(phoInd)) < 0.2 && (fabs(tree->phoEt_->at(phoInd) - tree->mcPt->at(mcInd)) / tree->mcPt->at(mcInd)) < 1.0; if( etetamatch && tree->mcPID->at(mcInd) == 22){ // test if(!(tree->mcParentage->at(mcInd)==2 || tree->mcParentage->at(mcInd)==10 || tree->mcParentage->at(mcInd)==26)) continue; // fill histograms for mathced photon candidate parentage->Fill( tree->mcParentage->at(mcInd) ); dptOverpt->Fill( (tree->phoEt_->at(phoInd) - tree->mcPt->at(mcInd)) / tree->mcPt->at(mcInd)); dRrecoGen->Fill( dR(tree->mcEta->at(mcInd),tree->mcPhi->at(mcInd),tree->phoEta_->at(phoInd),tree->phoPhi_->at(phoInd)) ); dPhiRecoGen->Fill( dPhi( tree->phoPhi_->at(phoInd) - tree->mcPhi->at(mcInd) ) ); dEtaRecoGen->Fill( tree->phoEta_->at(phoInd) - tree->mcEta->at(mcInd) ); int closestGenInd = secondMinDrIndex( mcInd, tree ); if(dR(tree->mcEta->at(mcInd), tree->mcPhi->at(mcInd), tree->mcEta->at(closestGenInd), tree->mcPhi->at(closestGenInd)) < 0.01){ std::cout << "closest PID " << tree->mcPID->at(closestGenInd) << " MomPID " << tree->mcMomPID->at(closestGenInd) << std::endl; std::cout << "photon mother PID " << tree->mcMomPID->at(mcInd) << std::endl; } dROtherGen->Fill( dR(tree->mcEta->at(mcInd), tree->mcPhi->at(mcInd), tree->mcEta->at(closestGenInd), tree->mcPhi->at(closestGenInd)) ); int closestJetInd = minDrIndex( tree->mcEta->at(mcInd), tree->mcPhi->at(mcInd), tree->jetEta_, tree->jetPhi_ ); dRGenNearJet->Fill( dR(tree->mcEta->at(mcInd), tree->mcPhi->at(mcInd), tree->jetEta_->at(closestJetInd), tree->jetPhi_->at(closestJetInd) ) ); dPhiGenNearJet->Fill( dPhi( tree->jetPhi_->at(closestJetInd) - tree->mcPhi->at(mcInd) ) ); dEtaGenNearJet->Fill( tree->jetEta_->at(closestJetInd) - tree->mcEta->at(mcInd) ); //closestJetInd = secondMinDrIndex( tree->mcEta->at(mcInd), tree->mcPhi->at(mcInd), tree->jetEta_, tree->jetPhi_ ); //dRGenNextNearJet->Fill( dR(tree->mcEta->at(mcInd), tree->mcPhi->at(mcInd), tree->jetEta_->at(closestJetInd), tree->jetPhi_->at(closestJetInd) ) ); //dPhiGenNextNearJet->Fill( dPhi( tree->jetPhi_->at(closestJetInd) - tree->mcPhi->at(mcInd) ) ); //dEtaGenNextNearJet->Fill( tree->jetEta_->at(closestJetInd) - tree->mcEta->at(mcInd) ); } } } evtPickLoose->print_cutflow(); // write histograms TFile outFile("signalAcc.root","RECREATE"); saveHist(allCategory, &outFile); saveHist(preselCategory, &outFile); saveHist(photonCategory, &outFile); saveHist(VisAllCategory, &outFile); saveHist(VisPreselCategory, &outFile); saveHist(VisPhotonCategory, &outFile); saveHist(dROtherGen, &outFile); saveHist(parentage, &outFile); saveHist(dptOverpt, &outFile); saveHist(dRrecoGen, &outFile); saveHist(dPhiRecoGen, &outFile); saveHist(dEtaRecoGen, &outFile); saveHist(dRGenNearJet, &outFile); saveHist(dPhiGenNearJet, &outFile); saveHist(dEtaGenNearJet, &outFile); //saveHist(dRGenNextNearJet, &outFile); //saveHist(dPhiGenNextNearJet, &outFile); //saveHist(dEtaGenNextNearJet, &outFile); outFile.Close(); delete tree; return 0; }
void doAll() { // // the looper // gSystem->Load("libTree.so"); gSystem->Load("libPhysics.so"); gSystem->Load("libEG.so"); gSystem->Load("libMathCore.so"); gSystem->Load("/tas/dlevans/HWW2012/CMSSW_5_2_3/src/LHAPDF-5.8.92b/lib/libLHAPDF.so"); gSystem->Load("libCMS2NtupleMacrosLooper.so"); // // create looper // // create a looper for a sample that was generated by using // CTEQ6LL. Check if this is the case for your sample! // generally, LO samples are generated with CTEQ6LL and // NLO samples are generated with CT10. Note that in the // CT10 case the central subset is at index 5, not 0. MyScanChain *looper_cteq6ll = new MyScanChain("cteq6ll.LHpdf", 0); // // run all pdf sets // std::vector<std::string> pdfSets; // CT10 pdfSets.push_back("CT10"); pdfSets.push_back("CT10as"); // MSTW pdfSets.push_back("MSTW2008nlo68cl"); pdfSets.push_back("MSTW2008nlo68cl_asmz+68cl"); pdfSets.push_back("MSTW2008nlo68cl_asmz+68clhalf"); pdfSets.push_back("MSTW2008nlo68cl_asmz-68cl"); pdfSets.push_back("MSTW2008nlo68cl_asmz-68clhalf"); // NNPDF pdfSets.push_back("NNPDF20_as_0116_100"); pdfSets.push_back("NNPDF20_as_0117_100"); pdfSets.push_back("NNPDF20_as_0118_100"); pdfSets.push_back("NNPDF20_100"); pdfSets.push_back("NNPDF20_as_0120_100"); pdfSets.push_back("NNPDF20_as_0121_100"); pdfSets.push_back("NNPDF20_as_0122_100"); // data sample TChain *chain_ttbar = new TChain("Events"); chain_ttbar->Add("/tas/dlevans_data/MCNtupling/CMSSW/CMSSW_5_3_2_patch4_V05-03-23/crab/makecms2ntuple/post_processed_ntuple.root"); // do gensets // the variation of the genset with respect to itself // is by definition 1.0, but we'll need this number later // stored just like all the others looper_cteq6ll->ScanChain("ttbar", chain_ttbar, "cteq6ll"); // do other sets for (unsigned int i = 0; i < pdfSets.size(); ++i) { std::cout << "===== Doing =====> " << pdfSets[i] << std::endl; looper_cteq6ll->ScanChain("ttbar", chain_ttbar, pdfSets[i]); } // // write histograms // const std::string outFile = "results.root"; saveHist(outFile.c_str()); deleteHistos(); // // tidy up // delete looper_cteq6ll; delete chain_ttbar; }