// Calo Matching ----------------------------------------- void HiForest::matchTrackCalo(bool allEvents){ if(allEvents || currentEvent == 0){ towerEt = new Float_t[maxEntry]; towerdR = new Float_t[maxEntry]; hbheEt = new Float_t[maxEntry]; hbhedR = new Float_t[maxEntry]; trackTree->Branch("towerEt",towerEt,"towerEt[nTrk]/F"); trackTree->Branch("towerdR",towerdR,"towerdR[nTrk]/F"); trackTree->Branch("hbhedR",hbheEt,"hbhedR[nTrk]/F"); trackTree->Branch("hbheEt",hbheEt,"hbheEt[nTrk]/F"); } for (int i=0; allEvents ? i<GetEntries() : 1;i++){ if(allEvents) GetEntry(i); for (int j=0;j<track.nTrk;j++) { int matchedTower = getMatchedCaloTowerAllowReuse(j); int matchedHBHE = getMatchedHBHEAllowReuse(j); float matchedTowerdR = deltaR(track.trkEta[j],track.trkPhi[j],tower.eta[matchedTower],tower.phi[matchedTower]); float matchedHbhedR = deltaR(track.trkEta[j],track.trkPhi[j],hbhe.eta[matchedHBHE],hbhe.phi[matchedHBHE]); towerEt[j]=tower.et[matchedTower]; towerdR[j]=matchedTowerdR; hbheEt[j]=hbhe.et[matchedHBHE]; hbhedR[j]=matchedHbhedR; } trackTree->Fill(); } }
double getProjectedZ(double jetpt, double jeteta, double jetphi, double trackpt, double tracketa, double trackphi, double eventEta = 0){ if(0){ double jetetaB = jeteta - eventEta; double tracketaB = tracketa - eventEta; double thetaJt = 2*atan(exp(-jetetaB)); double thetaTr = 2*atan(exp(-tracketaB)); double dphi = trackphi - jetphi; // angle between jet and track in dijet frame // Nooo - theta phi sit on curved space // double alpha = sqrt(fabs(thetaJt*thetaJt + thetaTr*thetaTr - 2* thetaTr*thetaJt*cos(dphi))); double alpha = acos(cos(dphi)*sin(thetaJt)*sin(thetaTr)+cos(thetaJt)*cos(thetaTr)); double pJet = jetpt/sin(thetaJt); double pTrack = trackpt/sin(thetaTr); return pTrack*cos(alpha)/pJet; }else{ double thetaJt = 2*atan(exp(-jeteta)); double thetaTr = 2*atan(exp(-tracketa)); double pTrack = trackpt/sin(thetaTr); double pJet = jetpt/sin(thetaJt); double dr = deltaR(jeteta,jetphi,tracketa,trackphi); return pTrack*cos(dr)/pJet; } }
double HiForest::getTrackCorrection(int j) { double trkWt = 0; if (track.trkAlgo[j]>=4&&!(track.highPurity[j])) return 0; if (initialized) { // check if the leading and subleading jet is found if (leadingJetPtForTrkCor<-1) { // Select leading and subleading jet for (int k=0; k<akPu3PF.nref; k++) { if (fabs(akPu3PF.jteta[k])>2) continue; if (akPu3PF.jtpt[k]>leadingJetPtForTrkCor) { leadingJetPtForTrkCor = akPu3PF.jtpt[k]; leadingJetEtaForTrkCor = akPu3PF.jteta[k]; leadingJetPhiForTrkCor = akPu3PF.jtphi[k]; } if (akPu3PF.jtpt[k]>subleadingJetPtForTrkCor && akPu3PF.jtpt[k] < leadingJetPtForTrkCor) { subleadingJetPtForTrkCor = akPu3PF.jtpt[k]; subleadingJetEtaForTrkCor = akPu3PF.jteta[k]; subleadingJetPhiForTrkCor = akPu3PF.jtphi[k]; } if (akPu3PF.jtpt[k]<subleadingJetPtForTrkCor) break; } } } else { cout <<"FATAL: Tracking correction is not initialized. Return 0, Please do HiForest->InitTree()."<<endl; return 0; } double dr1 = deltaR(track.trkEta[j], track.trkPhi[j],leadingJetEtaForTrkCor, leadingJetPhiForTrkCor); double dr2 = deltaR(track.trkEta[j], track.trkPhi[j],subleadingJetEtaForTrkCor, subleadingJetPhiForTrkCor); int leadingSet=0, subleadingSet=0; if (doTrackingSeparateLeadingSubleading) { leadingSet=1; subleadingSet=2; } if (leadingJetPtForTrkCor>=minJetPtForTrkCor&&dr1<0.5) { trkWt = trackCorrections[leadingSet]->GetCorr(track.trkPt[j],track.trkEta[j],leadingJetPtForTrkCor,evt.hiBin); } else if (subleadingJetPtForTrkCor>=minJetPtForTrkCor&&dr2<0.5) { trkWt = trackCorrections[subleadingSet]->GetCorr(track.trkPt[j],track.trkEta[j],subleadingJetPtForTrkCor,evt.hiBin); } else { trkWt = trackCorrections[0]->GetCorr(track.trkPt[j],track.trkEta[j],0,evt.hiBin); } return trkWt; }
unsigned int ElectronJet_OR(ObjAccess* ele, ObjAccess* jet, unsigned int iteration) { //Example Electron vs Jet //First Getting eta and phi of electron and jet float ele_eta = ele->GetValue<float>("_eta"); float ele_phi = ele->GetValue<float>("_phi"); //float ele_pt = ele->GetValue<float>("_pt"); //if (ele_pt < 10000.) cout << "ERROR electron pt during overlap removal "<<ele_pt <<endl; //float jet_eta = jet->GetValue<float>("_eta"); //float jet_phi = jet->GetValue<float>("_phi"); float jet_eta = jet->GetValue<float>("_emscale_eta"); float jet_phi = jet->GetValue<float>("_emscale_phi"); /* float jet_pt = ( jet->GetValue<float>("_emscale_pt")); float jes = jet->GetValue<float>("_EMJES"); //fix jes EMJESFixer jetEMJESfixer; if (jes ==0.) jes = jetEMJESfixer.fixAntiKt4H1Topo(jet_pt,jet_eta);; jet_pt = jes *jet_pt; if (jet_pt < 20000.) cout << "ERROR jet pt during overlap removal "<<jet_pt <<endl; if (jet_eta > 2.5) cout << "ERROR jet eta during overlap removal "<<jet_eta <<endl; */ //calculating deltaR float dR = deltaR(ele_eta,ele_phi,jet_eta,jet_phi); //cout << "overlap removal electron jet "<<endl; //Iteration 1 handinlig if (iteration == 1) { if (dR < 0.2) { // First and Second refer to the order in the method name. Here, first means Electron, second means Jet //cout << "dR = "<<dR<<" < 0.2 keep electron pt "<<ele_pt<<" and remove jet pt "<<jet_pt<<endl; return KEEP_FIRST; // OR return REJECT_SECOND --> KEEP ELECTRON, REJECT JET } } //Iteration 2 handling if (iteration == 2) { if (dR > 0.2 && dR < 0.4) { //cout << "0.2 <dR = "<<dR<<" < 0.4 remove electron pt "<<ele_pt<<" keep jet pt "<<jet_pt<<endl; return KEEP_SECOND;// OR return REJECT_FIRST --> KEEP JET, REJECT ELECTRON } } return KEEP_BOTH; //keep both if nothing happened }
void SVGReader::readDeltaRed(void) { Q_ASSERT(mXml.isStartElement() && mXml.name() == "deltared"); bool ok = false; const QString& redString = mXml.readElementText(); const int r = redString.toInt(&ok); if (ok) emit deltaR(r); else mXml.raiseError(QObject::tr("invalid delta red: %1").arg(redString)); }
unsigned short Particle::getClosest(const ParticleCollection& particles) const { unsigned short idOfClosest = 999; double closestDR = 999.; for (unsigned short index = 0; index < particles.size(); ++index) { double DR = deltaR(particles.at(index)); if (DR < closestDR) { closestDR = DR; idOfClosest = index; } } return idOfClosest; }
double TagAndProbe::ElecActivity( double elecEta, double elecPhi, unsigned int method) { double result =0; if(method==0) { for (unsigned int i=0; i < JetsNum ; i++) { if(deltaR(elecEta,elecPhi,JetsEta[i],JetsPhi[i])>maxDeltaRElecActivity_ ) continue; result+=JetsPt[i] * (Jets_chargedHadronEnergyFraction[i]); // result+=JetsPt[i] * (Jets_chargedEmEnergyFraction[i] + Jets_chargedHadronEnergyFraction[i]); } } if(method==1) { for (unsigned int i=0; i < JetsNum ; i++) { if(deltaR(elecEta,elecPhi,JetsEta[i],JetsPhi[i])>maxDeltaRElecActivity_ ) continue; result+=JetsPt[i] * (Jets_chargedHadronEnergyFraction[i])*(1/(deltaR(elecEta,elecPhi,JetsEta[i],JetsPhi[i])+0.5)); } } if(method==2) { for(unsigned int i=0; i< SelectedPFCandidatesNum; i++) { if(deltaR(elecEta,elecPhi,SelectedPFCandidatesEta[i],SelectedPFCandidatesPhi[i])>maxDeltaRElecActivity_ ) continue; result+=SelectedPFCandidatesPt[i]; } } if(method==3) { for(unsigned int i=0; i< SelectedPFCandidatesNum; i++) { if(SelectedPFCandidates_Charge[i]!=0) continue; if(deltaR(elecEta,elecPhi,SelectedPFCandidatesEta[i],SelectedPFCandidatesPhi[i])>maxDeltaRElecActivity_ ) continue; result+=SelectedPFCandidatesPt[i]; } } return result; }
bool matchL1MuonWithGen(L1MuonCand mu, std::vector<GenParticleCand> Gencands){ bool match = false; float minDR = 1.0; float theDR = 100; for ( std::vector<GenParticleCand>::const_iterator it = Gencands.begin(); it != Gencands.end(); ++it ) { theDR = deltaR(it -> eta, it -> phi, mu.eta, mu.phi); if (theDR < minDR){ minDR = theDR; match = true; } } return match; }
bool matchMuonWithL3(MuonCand mu, std::vector<HLTMuonCand> L3cands){ bool match = false; float minDR = 0.1; float theDR = 100; for ( std::vector<HLTMuonCand>::const_iterator it = L3cands.begin(); it != L3cands.end(); ++it ) { theDR = deltaR(it -> eta, it -> phi, mu.eta, mu.phi); if (theDR < minDR){ minDR = theDR; match = true; } } return match; }
unsigned int TauMuon_OR(ObjAccess* tau, ObjAccess* muo, unsigned int /*iteration*/) { float muo_eta = muo->GetValue<float>("_eta"); float muo_phi = muo->GetValue<float>("_phi"); float tau_eta = tau->GetValue<float>("_eta"); float tau_phi = tau->GetValue<float>("_phi"); float dR = deltaR(muo_eta,muo_phi,tau_eta,tau_phi); //std::cout << " mu_jet dR " << dR << std::endl; if (dR < 0.4 ) return REJECT_SECOND; return KEEP_BOTH; }
Bool_t mjj_match::matchGenToParton(Int_t igen, Int_t ijet){ Bool_t matched = false; Double_t dR = deltaR(genParEta_->at(igen), genParPhi_->at(igen), genJetEta_->at(ijet), genJetPhi_->at(ijet) ); Double_t relPt = genParPt_->at(igen)>1e-6? fabs(genParPt_->at(igen)-genJetPt_->at(ijet))/genParPt_->at(igen) : -9999.0; if(dR<0.4) matched = true; return matched; }
unsigned int MuonJet_OR(ObjAccess* muo, ObjAccess* jet, unsigned int /*iteration*/) { float muo_eta = muo->GetValue<float>("_eta"); float muo_phi = muo->GetValue<float>("_phi"); float jet_eta = jet->GetValue<float>("_eta"); float jet_phi = jet->GetValue<float>("_phi"); float dR = deltaR(muo_eta,muo_phi,jet_eta,jet_phi); //std::cout << " mu_jet dR " << dR << std::endl; if (dR < 0.4 ) return REJECT_FIRST; return KEEP_BOTH; }
unsigned int TauElectron_OR(ObjAccess* tau, ObjAccess* ele, unsigned int /*iteration*/) { float tau_eta = tau->GetValue<float>("_eta"); float tau_phi = tau->GetValue<float>("_phi"); float ele_eta = ele->GetValue<float>("_eta"); float ele_phi = ele->GetValue<float>("_phi"); float dR = deltaR(tau_eta,tau_phi,ele_eta,ele_phi); //std::cout << " mu_jet dR " << dR << std::endl; if (dR < 0.4 ) return REJECT_FIRST; return KEEP_BOTH; }
unsigned int TauJet_OR(ObjAccess* tau, ObjAccess* jet, unsigned int /*iteration*/) { float tau_eta = tau->GetValue<float>("_eta"); float tau_phi = tau->GetValue<float>("_phi"); float jet_eta = jet->GetValue<float>("_eta"); float jet_phi = jet->GetValue<float>("_phi"); float dR = deltaR(tau_eta,tau_phi,jet_eta,jet_phi); //std::cout << " mu_jet dR " << dR << std::endl; if (dR < 0.4 ) return REJECT_SECOND; return KEEP_BOTH; }
bool matchMuon(MuonCand mu, std::vector<HLTObjCand> toc, std::string tagFilterName){ bool match = false; int ntoc = toc.size(); float minDR = 0.2; if (tagFilterName.find("L1fL1") != std::string::npos) minDR = 1.0; float theDR = 100; for ( std::vector<HLTObjCand>::const_iterator it = toc.begin(); it != toc.end(); ++it ) { if ( it->filterTag.compare(tagFilterName) == 0) { theDR = deltaR(it -> eta, it -> phi, mu.eta, mu.phi); if (theDR < minDR){ minDR = theDR; match = true; } } } return match; }
unsigned int MuonJet_OR(ObjAccess* muo, ObjAccess* jet, unsigned int /*iteration*/) { float muo_eta = muo->GetValue<float>("_eta"); float muo_phi = muo->GetValue<float>("_phi"); //float jet_eta = jet->GetValue<float>("_eta"); //float jet_phi = jet->GetValue<float>("_phi"); float jet_eta = jet->GetValue<float>("_emscale_eta"); float jet_phi = jet->GetValue<float>("_emscale_phi"); float dR = deltaR(muo_eta,muo_phi,jet_eta,jet_phi); //float muo_pt = muo->GetValue<float>("_pt"); //if (muo_pt < 10000.) cout << "ERROR muon pt during overlap removal "<<muo_pt <<endl; //std::cout << " mu_jet dR " << dR << std::endl; if (dR < 0.4 ) return REJECT_FIRST; // --> KEEP JET, REJECT MUON return KEEP_BOTH; }
double jetHadFraction(Jets& jets, int ijet, Hits& hbhe, double radius = 0.3){ double x = 0; double jeteta = jets.jteta[ijet]; double jetphi = jets.jtphi[ijet]; double jetenergy = jets.rawpt[ijet] + jets.jtpu[ijet]; for(int i = 0; i < hbhe.n; ++i){ double eta = hbhe.eta[i]; double phi = hbhe.phi[i]; double dr = deltaR(jeteta,jetphi,eta,phi); if(dr < radius){ x+= hbhe.et[i]; } } return x/jetenergy; }
bool matchMuon(GenParticleCand mu, std::vector<HLTObjCand> toc, std::string tagFilterName){ bool match = false; int ntoc = toc.size(); float minDR = 0.1; if (tagFilterName.find("L1fL1") != std::string::npos) minDR = 1.0; float theDR = 100; for ( std::vector<HLTObjCand>::const_iterator it = toc.begin(); it != toc.end(); ++it ) { //if (debug) cout << tagFilterName << " = " << it->filterTag << " ? " << endl; if ( it->filterTag.compare(tagFilterName) == 0) { // if (debug) cout << " YES" << endl; theDR = deltaR(it -> eta, it -> phi, mu.eta, mu.phi); if (theDR < minDR){ minDR = theDR; match = true; } } } return match; }
unsigned int ElectronJet_OR(ObjAccess* ele, ObjAccess* jet, unsigned int iteration) { //Example Electron vs Jet //First Getting eta and phi of electron and jet float ele_eta = ele->GetValue<float>("_eta"); float ele_phi = ele->GetValue<float>("_phi"); float jet_eta = jet->GetValue<float>("_eta"); float jet_phi = jet->GetValue<float>("_phi"); //calculating deltaR float dR = deltaR(ele_eta,ele_phi,jet_eta,jet_phi); //Iteration 1 handinlig if (iteration == 1) { if (dR < 0.2) { // First and Second refer to the order in the method name. Here, first means Electron, second means Jet return KEEP_FIRST; // OR return REJECT_SECOND; } } //Iteration 2 handling if (iteration == 2) { if (dR > 0.2 && dR < 0.4) { return KEEP_SECOND;// OR return REJECT_FIRST; } } return KEEP_BOTH; //keep both if nothing happened }
void vbf_bbbb_select(const TString confname="test_vbf.txt", const Float_t xsec=1.0, const Float_t totalEvents=100, const TString outputfile="test.root") { // declare constants const Int_t B_ID_CODE = 5; const Int_t H_ID_CODE = 25; const Float_t MAX_MATCH_DIST = 0.5; // read input input file TChain chain("Delphes"); TString inputfile; ifstream ifs; ifs.open(confname); assert(ifs.is_open()); string line; while (getline(ifs, line)) { stringstream ss(line);; ss >> inputfile; chain.Add(inputfile); } ifs.close(); ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); TClonesArray *branchJet = treeReader->UseBranch("Jet"); TClonesArray *branchGenJet = treeReader->UseBranch("GenJet"); TClonesArray *branchParticle = treeReader->UseBranch("Particle"); //set up loop variables GenParticle *genParticle=0; Jet *genJet=0; Jet *jet=0; // set up storage variables Jet *jetB1=0, *jetB2=0, *jetB3=0, *jetB4=0; Jet *jet1=0, *jet2=0; GenParticle *genB1=0, *genB2=0, *genB3=0, *genB4=0; GenParticle *genH1=0, *genH2=0; Jet *genJetB1=0, *genJetB2=0, *genJetB3=0, *genJetB4=0; Jet *genJetVBF1=0, *genJetVBF2=0; Int_t iB1=-1, iB2=-1, iB3=-1, iB4=-1; Int_t iH1=-1, iH2=-1; Int_t iJet1=-1, iJet2=-1; Int_t iGenB1=-1, iGenB2=-1, iGenB3=-1, iGenB4=-1; Int_t iGenJetB1=-1, iGenJetB2=-1, iGenJetB3=-1, iGenJetB4=-1; Int_t iGenJetVBF1=-1, iGenJetVBF2=-1; Int_t iHmatch1=-1, iHmatch2=-1, iHmatch3=-1, iHmatch4=-1; LorentzVector *sRecoB1=0, *sRecoB2=0, *sRecoB3=0, *sRecoB4=0; LorentzVector *sGenJetB1=0, *sGenJetB2=0, *sGenJetB3=0, *sGenJetB4=0; LorentzVector *sGenJetVBF1=0, *sGenJetVBF2=0; LorentzVector *sGenB1=0, *sGenB2=0, *sGenB3=0, *sGenB4=0; LorentzVector *sGenH1=0, *sGenH2=0; LorentzVector *sRecoJet1=0, *sRecoJet2=0; TFile *outFile = new TFile(outputfile, "RECREATE"); // tree to hold information about selected events TTree *outTree = new TTree("Events", "Events"); outTree->Branch("iHmatch1", &iHmatch1, "iHmatch1/i"); // which Higgs does b-jet 1 come from outTree->Branch("iHmatch2", &iHmatch2, "iHmatch2/i"); // which Higgs does b-jet 2 come from outTree->Branch("iHmatch3", &iHmatch3, "iHmatch3/i"); // which Higgs does b-jet 3 come from outTree->Branch("iHmatch4", &iHmatch4, "iHmatch4/i"); // which Higgs does b-jet 4 come from outTree->Branch("sGenB1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenB1); // 4-vector for generator leading b-jet outTree->Branch("sGenB2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenB2); // 4-vector for generator b-jet outTree->Branch("sGenB3", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenB3); // 4-vector for generator b-jet outTree->Branch("sGenB4", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenB4); // 4-vector for generator b-jet outTree->Branch("sGenH1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenH1); // 4-vector for generator higgs outTree->Branch("sGenH2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenH2); // 4-vector for generator higgs outTree->Branch("sGenJetB1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetB1); // 4-vector for generator leading b-jet outTree->Branch("sGenJetB2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetB2); // 4-vector for generator b-jet outTree->Branch("sGenJetB3", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetB3); // 4-vector for generator b-jet outTree->Branch("sGenJetB4", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetB4); // 4-vector for generator b-jet outTree->Branch("sGenJetVBF1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetVBF1); // 4-vector for generator leading b-jet outTree->Branch("sGenJetVBF2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetVBF2); // 4-vector for generator b-jet outTree->Branch("sRecoB1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoB1); // 4-vector for reconstructed leading b-jet outTree->Branch("sRecoB2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoB2); // 4-vector for reconstructed b-jet outTree->Branch("sRecoB3", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoB3); // 4-vector for reconstructed b-jet outTree->Branch("sRecoB4", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoB4); // 4-vector for reconstructed b-jet outTree->Branch("sRecoJet1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoJet1); // 4-vector for reconstructed leading forward-jet outTree->Branch("sRecoJet2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoJet2); // 4-vector for reconstructed second forward-jet // define placeholder vector for things that don't exist LorentzVector nothing(-999,-999,0,-999); Int_t iMatched=0; Int_t iNot=0; Int_t iTwo=0; Int_t nM=0; for (Int_t iEntry=0; iEntry<numberOfEntries; iEntry++) { // entry loop treeReader->ReadEntry(iEntry); // ******************** // RESET // ******************** iB1=-1; iB2=-1; iB3=-1; iB4=-1; iGenB1=-1; iGenB2=-1; iGenB3=-1; iGenB4=-1; iGenJetB1=-1; iGenJetB2=-1; iGenJetB3=-1; iGenJetB4=-1; iGenJetVBF1=-1; iGenJetVBF2=-1; iH1=-1; iH2=-1; iJet1=-1; iJet2=-1; iHmatch1=-1; iHmatch2=-1; iHmatch3=-1; iHmatch4=-1; jet1=0; jet2=0; jetB1=0; jetB2=0; jetB3=0; jetB4=0; genB1=0; genB2=0; genB3=0; genB4=0; genJetB1=0; genJetB2=0; genJetB3=0; genJetB4=0; genJetVBF1=0; genJetVBF2=0; sGenB1=0; sGenB2=0; sGenB3=0; sGenB4=0; sGenJetB1=0; sGenJetB2=0; sGenJetB3=0; sGenJetB4=0; sGenJetVBF1=0; sGenJetVBF2=0; sGenH1=0; sGenH2=0; nM=0; for (Int_t iJet=0; iJet<branchJet->GetEntries(); iJet++) { // reconstructed jet loop jet = (Jet*) branchJet->At(iJet); if (fabs(jet->Eta)>4.0) continue; if (jet->PT<30) continue; if (puJetID(jet->Eta, jet->MeanSqDeltaR, jet->BetaStar)==1) continue; if (jet->BTag==0) continue; if ((jetB1)&&(deltaR(jet->Eta, jetB1->Eta, jet->Phi, jetB1->Phi) < MAX_MATCH_DIST)) continue; if ((jetB2)&&(deltaR(jet->Eta, jetB2->Eta, jet->Phi, jetB2->Phi) < MAX_MATCH_DIST)) continue; if ((jetB3)&&(deltaR(jet->Eta, jetB3->Eta, jet->Phi, jetB3->Phi) < MAX_MATCH_DIST)) continue; if ((jetB4)&&(deltaR(jet->Eta, jetB4->Eta, jet->Phi, jetB4->Phi) < MAX_MATCH_DIST)) continue; if (iB1==-1) { iB1=iJet; jetB1 = (Jet*) branchJet->At(iB1); } else if (jet->PT > jetB1->PT) { iB4=iB3; jetB4 = (Jet*) branchJet->At(iB4); iB3=iB2; jetB3 = (Jet*) branchJet->At(iB3); iB2=iB1; jetB2 = (Jet*) branchJet->At(iB2); iB1=iJet; jetB1 = (Jet*) branchJet->At(iB1); } else if (iB2==-1) { iB2=iJet; jetB2 = (Jet*) branchJet->At(iB2); } else if (jet->PT > jetB2->PT) { iB4=iB3; jetB4 = (Jet*) branchJet->At(iB4); iB3=iB2; jetB3 = (Jet*) branchJet->At(iB3); iB2=iJet; jetB2 = (Jet*) branchJet->At(iB2); } else if (iB3==-1) { iB3=iJet; jetB3 = (Jet*) branchJet->At(iB3); } else if (jet->PT > jetB3->PT) { iB4=iB3; jetB4 = (Jet*) branchJet->At(iB4); iB3=iB2; jetB3 = (Jet*) branchJet->At(iB3); } else if (iB4==-1) { iB4=iJet; jetB4 = (Jet*) branchJet->At(iB4); } else if (jet->PT > jetB4->PT) { iB4=iJet; jetB4 = (Jet*) branchJet->At(iB4); } } // end reco jet loop // get VBF jets for (Int_t iJet=0; iJet<branchJet->GetEntries(); iJet++) { // reconstructed jet loop jet = (Jet*) branchJet->At(iJet); if (fabs(jet->Eta)>4.7) continue; if (jet->PT<30) continue; if (puJetID(jet->Eta, jet->MeanSqDeltaR, jet->BetaStar)==1) continue; if ((jetB1)&&(deltaR(jet->Eta, jetB1->Eta, jet->Phi, jetB1->Phi) < MAX_MATCH_DIST)) continue; if ((jetB2)&&(deltaR(jet->Eta, jetB2->Eta, jet->Phi, jetB2->Phi) < MAX_MATCH_DIST)) continue; if ((jetB3)&&(deltaR(jet->Eta, jetB3->Eta, jet->Phi, jetB3->Phi) < MAX_MATCH_DIST)) continue; if ((jetB4)&&(deltaR(jet->Eta, jetB4->Eta, jet->Phi, jetB4->Phi) < MAX_MATCH_DIST)) continue; if (iJet1==-1) { iJet1=iJet; jet1 = (Jet*) branchJet->At(iJet1); } else if (jet->PT > jet1->PT) { iJet2=iJet1; jet2 = (Jet*) branchJet->At(iJet2); iJet1=iJet; jet1 = (Jet*) branchJet->At(iJet1); } else if (iJet2==-1) { iJet2=iJet; jet2 = (Jet*) branchJet->At(iJet2); } else if (jet->PT > jet2->PT) { iJet2=iJet; jet2 = (Jet*) branchJet->At(iJet2); } } if ( (!jetB1) || (!jetB2) || (!jetB3) || (!jetB4) || (!jet1) || (!jet2) ) continue; /* cout << "stored jets" << endl; if (jetB1) cout << "1 " << jetB1->PT << " " << jetB1->Eta << endl; if (jetB2) cout << "2 " << jetB2->PT << " " << jetB2->Eta << endl; if (jetB3) cout << "3 " << jetB3->PT << " " << jetB3->Eta << endl; if (jetB4) cout << "4 " << jetB4->PT << " " << jetB4->Eta << endl; if (jet1) cout << "V1 " << jet1->PT << " " << jet1->Eta << endl; if (jet2) cout << "V2 " << jet2->PT << " " << jet2->Eta << endl; cout << endl;*/ // fill 4-vector for leading b-jet LorentzVector vRecoB1(0,0,0,0); if (jetB1) { vRecoB1.SetPt(jetB1->PT); vRecoB1.SetEta(jetB1->Eta); vRecoB1.SetPhi(jetB1->Phi); vRecoB1.SetM(jetB1->Mass); sRecoB1 = &vRecoB1; } else sRecoB1 = ¬hing; // fill 4-vector for b-jet LorentzVector vRecoB2(0,0,0,0); if (jetB2) { vRecoB2.SetPt(jetB2->PT); vRecoB2.SetEta(jetB2->Eta); vRecoB2.SetPhi(jetB2->Phi); vRecoB2.SetM(jetB2->Mass); sRecoB2 = &vRecoB2; } else sRecoB2 = ¬hing; // fill 4-vector for b-jet LorentzVector vRecoB3(0,0,0,0); if (jetB3) { vRecoB3.SetPt(jetB3->PT); vRecoB3.SetEta(jetB3->Eta); vRecoB3.SetPhi(jetB3->Phi); vRecoB3.SetM(jetB3->Mass); sRecoB3 = &vRecoB3; } else sRecoB3 = ¬hing; // fill 4-vector for b-jet LorentzVector vRecoB4(0,0,0,0); if (jetB4) { vRecoB4.SetPt(jetB4->PT); vRecoB4.SetEta(jetB4->Eta); vRecoB4.SetPhi(jetB4->Phi); vRecoB4.SetM(jetB4->Mass); sRecoB4 = &vRecoB4; } else sRecoB4 = ¬hing; // ******************** // GEN PARTICLES // ******************** //cout << "B-QUARKS: " << endl; for (Int_t iParticle=0; iParticle<branchParticle->GetEntries(); iParticle++) { // generator particle loop genParticle = (GenParticle*) branchParticle->At(iParticle); if ( fabs(genParticle->PID) != B_ID_CODE ) continue; if (genParticle->Status != 3) continue; //cout << genParticle->PT << " " << genParticle->Eta << " " << genParticle->Phi << " " << genParticle->Status << endl; if ( deltaR(genParticle->Eta, vRecoB1.Eta(), genParticle->Phi, vRecoB1.Phi()) < MAX_MATCH_DIST ) { iGenB1 = iParticle; genB1 = (GenParticle*) branchParticle->At(iGenB1); } else if ( deltaR(genParticle->Eta, vRecoB2.Eta(), genParticle->Phi, vRecoB2.Phi()) < MAX_MATCH_DIST ) { iGenB2 = iParticle; genB2 = (GenParticle*) branchParticle->At(iGenB2); } else if ( deltaR(genParticle->Eta, vRecoB3.Eta(), genParticle->Phi, vRecoB3.Phi()) < MAX_MATCH_DIST ) { iGenB3 = iParticle; genB3 = (GenParticle*) branchParticle->At(iGenB3); } else if ( deltaR(genParticle->Eta, vRecoB4.Eta(), genParticle->Phi, vRecoB4.Phi()) < MAX_MATCH_DIST ) { iGenB4 = iParticle; genB4 = (GenParticle*) branchParticle->At(iGenB4); } } /* cout << "Gen Particles " << endl; if (genB1) cout << "1 " << genB1->PT << " " << genB1->Eta << endl; if (genB2) cout << "2 " << genB2->PT << " " << genB2->Eta << endl; if (genB3) cout << "3 " << genB3->PT << " " << genB3->Eta << endl; if (genB4) cout << "4 " << genB4->PT << " " << genB4->Eta << endl; */ for (Int_t iParticle=0; iParticle<branchParticle->GetEntries(); iParticle++) { // generator particle loop genParticle = (GenParticle*) branchParticle->At(iParticle); if (fabs(genParticle->PID) != H_ID_CODE) continue; if (iH1==-1) { iH1 = iParticle; genH1 = (GenParticle*) branchParticle->At(iH1); } else if (iH2==-1) { iH2 = iParticle; genH2 = (GenParticle*) branchParticle->At(iH2); } } /* if (genH1) cout << "H1 " << genH1->PT << " " << genH1->Eta << " " << genH1->Phi << endl; if (genH2) cout << "H2 " << genH2->PT << " " << genH2->Eta << " " << genH2->Phi << endl; cout << endl;*/ LorentzVector vGenB1(0,0,0,0); if (genB1) { vGenB1.SetPt(genB1->PT); vGenB1.SetEta(genB1->Eta); vGenB1.SetPhi(genB1->Phi); vGenB1.SetM(genB1->Mass); sGenB1 = &vGenB1; } else sGenB1 = ¬hing; LorentzVector vGenB2(0,0,0,0); if (genB2) { vGenB2.SetPt(genB2->PT); vGenB2.SetEta(genB2->Eta); vGenB2.SetPhi(genB2->Phi); vGenB2.SetM(genB2->Mass); sGenB2 = &vGenB2; } else sGenB2 = ¬hing; LorentzVector vGenB3(0,0,0,0); if (genB3) { vGenB3.SetPt(genB3->PT); vGenB3.SetEta(genB3->Eta); vGenB3.SetPhi(genB3->Phi); vGenB3.SetM(genB3->Mass); sGenB3 = &vGenB3; } else sGenB3 = ¬hing; LorentzVector vGenB4(0,0,0,0); if (genB4) { vGenB4.SetPt(genB4->PT); vGenB4.SetEta(genB4->Eta); vGenB4.SetPhi(genB4->Phi); vGenB4.SetM(genB4->Mass); sGenB4 = &vGenB4; } else sGenB4 = ¬hing; LorentzVector vGenH1(0,0,0,0); if (genH1) { vGenH1.SetPt(genH1->PT); vGenH1.SetEta(genH1->Eta); vGenH1.SetPhi(genH1->Phi); vGenH1.SetM(genH1->Mass); sGenH1 = &vGenH1; } else sGenH1 = ¬hing; LorentzVector vGenH2(0,0,0,0); if (genH2) { vGenH2.SetPt(genH2->PT); vGenH2.SetEta(genH2->Eta); vGenH2.SetPhi(genH2->Phi); vGenH2.SetM(genH2->Mass); sGenH2 = &vGenH2; } else sGenH2 = ¬hing; LorentzVector vTestBB1=vGenB1+vGenB2; LorentzVector vTestBB2=vGenB3+vGenB4; //cout << "test1 " << vTestBB1.Pt() << " " << vTestBB1.Eta() << " " << vTestBB1.Phi() << endl; //cout << "test1 " << vTestBB2.Pt() << " " << vTestBB2.Eta() << " " << vTestBB2.Phi() << endl; cout << "---" << endl; if ( (deltaR(vTestBB1.Eta(), vGenH1.Eta(), vTestBB1.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB2.Eta(), vGenH2.Eta(), vTestBB2.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=1; iHmatch2=1; iHmatch3=2; iHmatch4=2; } else if ( (deltaR(vTestBB2.Eta(), vGenH1.Eta(), vTestBB2.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB1.Eta(), vGenH2.Eta(), vTestBB1.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=2; iHmatch2=2; iHmatch3=1; iHmatch4=1; } vTestBB1=vGenB1+vGenB3; vTestBB2=vGenB2+vGenB4; //cout << "test2 " << vTestBB1.Pt() << " " << vTestBB1.Eta() << " " << vTestBB1.Phi() << endl; //cout << "test2 " << vTestBB2.Pt() << " " << vTestBB2.Eta() << " " << vTestBB2.Phi() << endl; if ( (deltaR(vTestBB1.Eta(), vGenH1.Eta(), vTestBB1.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB2.Eta(), vGenH2.Eta(), vTestBB2.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=1; iHmatch2=2; iHmatch3=1; iHmatch4=2; } else if ( (deltaR(vTestBB2.Eta(), vGenH1.Eta(), vTestBB2.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB1.Eta(), vGenH2.Eta(), vTestBB1.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=2; iHmatch2=1; iHmatch3=2; iHmatch4=1; } vTestBB1=vGenB1+vGenB4; vTestBB2=vGenB3+vGenB2; //cout << "test3 " << vTestBB1.Pt() << " " << vTestBB1.Eta() << " " << vTestBB1.Phi() << endl; //cout << "test3 " << vTestBB2.Pt() << " " << vTestBB2.Eta() << " " << vTestBB2.Phi() << endl; if ( (deltaR(vTestBB1.Eta(), vGenH1.Eta(), vTestBB1.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB2.Eta(), vGenH2.Eta(), vTestBB2.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=1; iHmatch2=2; iHmatch3=2; iHmatch4=1; } else if ( (deltaR(vTestBB2.Eta(), vGenH1.Eta(), vTestBB2.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB1.Eta(), vGenH2.Eta(), vTestBB1.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=2; iHmatch2=1; iHmatch3=1; iHmatch4=2; } if (iHmatch1==-1) { iHmatch1=0; iHmatch2=0; iHmatch3=0; iHmatch4=0; } //cout << iHmatch1 << " " << iHmatch2 << " " << iHmatch3 << " " << iHmatch4 << endl; //cout << endl; if (nM==0) iNot++; else if (nM==1) iMatched++; else if (nM>1) iTwo++; // match gen jets to reco jets for (Int_t iJet=0; iJet<branchGenJet->GetEntries(); iJet++) { // generator level jet loop genJet = (Jet*) branchGenJet->At(iJet); if ((jetB1) && (deltaR(genJet->Eta, jetB1->Eta, genJet->Phi, jetB1->Phi) < MAX_MATCH_DIST) ) { iGenJetB1=iJet; genJetB1 = (Jet*) branchGenJet->At(iGenJetB1); } else if ((jetB2) && (deltaR(genJet->Eta, jetB2->Eta, genJet->Phi, jetB2->Phi) < MAX_MATCH_DIST) ) { iGenJetB2=iJet; genJetB2 = (Jet*) branchGenJet->At(iGenJetB2); } else if ((jetB3) && (deltaR(genJet->Eta, jetB3->Eta, genJet->Phi, jetB3->Phi) < MAX_MATCH_DIST) ) { iGenJetB3=iJet; genJetB3 = (Jet*) branchGenJet->At(iGenJetB3); } else if ((jetB4) && (deltaR(genJet->Eta, jetB4->Eta, genJet->Phi, jetB4->Phi) < MAX_MATCH_DIST) ) { iGenJetB4=iJet; genJetB4 = (Jet*) branchGenJet->At(iGenJetB4); } else if ((jet1) && (deltaR(genJet->Eta, jet1->Eta, genJet->Phi, jet1->Phi) < MAX_MATCH_DIST) ) { iGenJetVBF1=iJet; genJetVBF1 = (Jet*) branchGenJet->At(iGenJetVBF1); } else if ((jet2) && (deltaR(genJet->Eta, jet2->Eta, genJet->Phi, jet2->Phi) < MAX_MATCH_DIST) ) { iGenJetVBF2=iJet; genJetVBF2 = (Jet*) branchGenJet->At(iGenJetVBF2); } } LorentzVector vGenJetB1(0,0,0,0); if (genJetB1) { vGenJetB1.SetPt(genJetB1->PT); vGenJetB1.SetEta(genJetB1->Eta); vGenJetB1.SetPhi(genJetB1->Phi); vGenJetB1.SetM(genJetB1->Mass); sGenJetB1 = &vGenJetB1; } else sGenJetB1 = ¬hing; LorentzVector vGenJetB2(0,0,0,0); if (genJetB2) { vGenJetB2.SetPt(genJetB2->PT); vGenJetB2.SetEta(genJetB2->Eta); vGenJetB2.SetPhi(genJetB2->Phi); vGenJetB2.SetM(genJetB2->Mass); sGenJetB2 = &vGenJetB2; } else sGenJetB2 = ¬hing; LorentzVector vGenJetB3(0,0,0,0); if (genJetB3) { vGenJetB3.SetPt(genJetB3->PT); vGenJetB3.SetEta(genJetB3->Eta); vGenJetB3.SetPhi(genJetB3->Phi); vGenJetB3.SetM(genJetB3->Mass); sGenJetB3 = &vGenJetB3; } else sGenJetB3 = ¬hing; LorentzVector vGenJetB4(0,0,0,0); if (genJetB4) { vGenJetB4.SetPt(genJetB4->PT); vGenJetB4.SetEta(genJetB4->Eta); vGenJetB4.SetPhi(genJetB4->Phi); vGenJetB4.SetM(genJetB4->Mass); sGenJetB4 = &vGenJetB4; } else sGenJetB4 = ¬hing; LorentzVector vGenJetVBF1(0,0,0,0); if (genJetVBF1) { vGenJetVBF1.SetPt(genJetVBF1->PT); vGenJetVBF1.SetEta(genJetVBF1->Eta); vGenJetVBF1.SetPhi(genJetVBF1->Phi); vGenJetVBF1.SetM(genJetVBF1->Mass); sGenJetVBF1 = &vGenJetVBF1; } else sGenJetVBF1 = ¬hing; LorentzVector vGenJetVBF2(0,0,0,0); if (genJetVBF2) { vGenJetVBF2.SetPt(genJetVBF2->PT); vGenJetVBF2.SetEta(genJetVBF2->Eta); vGenJetVBF2.SetPhi(genJetVBF2->Phi); vGenJetVBF2.SetM(genJetVBF2->Mass); sGenJetVBF2 = &vGenJetVBF2; } else sGenJetVBF2 = ¬hing; /* cout << "Gen Jets " << endl; if (genJetB1) cout << "1 " << genJetB1->PT << " " << genJetB1->Eta << endl; if (genJetB2) cout << "2 " << genJetB2->PT << " " << genJetB2->Eta << endl; if (genJetB3) cout << "3 " << genJetB3->PT << " " << genJetB3->Eta << endl; if (genJetB4) cout << "4 " << genJetB4->PT << " " << genJetB4->Eta << endl; if (genJetVBF1) cout << "V1 " << genJetVBF1->PT << " " << genJetVBF1->Eta << endl; if (genJetVBF2) cout << "V2 " << genJetVBF2->PT << " " << genJetVBF2->Eta << endl; cout << endl; */ outTree->Fill(); } // end event loop outFile->Write(); outFile->Save(); cout << endl; cout << "matched : " << iMatched << endl; cout << "not : " << iNot << endl; cout << "too much : " << iTwo << endl; cout << "total : " << iMatched+iNot+iTwo << endl; }
//!PG main function int selector (TChain * tree, histos & plots, int if_signal) { plots.v_hardTAGPt = -99; plots.v_softTAGPt = -99; plots.v_TAGDProdEta = -99; plots.v_TAGDeta = -99; plots.v_TAGMinv = -99; plots.v_LepLep = -99; plots.v_hardLEPPt = -99; plots.v_softLEPPt = -99; plots.v_LEPDPhi = -99; plots.v_LEPDEta = -99; plots.v_LEPDR = -99; plots.v_LEPMinv = -99; plots.v_LEPProdCharge = -99; plots.v_hardLEPCharge = -99; plots.v_softLEPCharge = -99; plots.v_MET = -99; plots.v_ojets = -99 ; plots.v_ojetsCJV = -99 ; plots.v_ojetsRegionalCJV = -99 ; plots.v_ojetsZepp_01 = -99 ; plots.v_ojetsZepp_02 = -99 ; plots.v_ojetsZepp_03 = -99 ; plots.v_ojetsZepp_04 = -99 ; plots.v_ojetsZepp_05 = -99 ; plots.v_ojetsZepp_06 = -99 ; plots.v_ojetsZepp_07 = -99 ; plots.v_ojetsZepp_08 = -99 ; plots.v_ojetsZepp_09 = -99 ; plots.v_ojetsZepp_10 = -99 ; plots.v_ojetsZepp_11 = -99 ; plots.v_ojetsZepp_12 = -99 ; plots.v_ojetsZepp_13 = -99 ; plots.v_ojetsZepp_14 = -99 ; plots.v_decay_Channel_e = -99 ; plots.v_decay_Channel_mu = -99 ; plots.v_decay_Channel_tau = -99 ; TClonesArray * genParticles = new TClonesArray ("TParticle") ; tree->SetBranchAddress ("genParticles", &genParticles) ; // TClonesArray * tagJets = new TClonesArray ("TLorentzVector") ; // tree->SetBranchAddress ("tagJets", &tagJets) ; TClonesArray * otherJets_temp = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress (g_KindOfJet.c_str(), &otherJets_temp) ; // tree->SetBranchAddress ("otherJets", &otherJets_temp) ; TClonesArray * electrons = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("electrons", &electrons) ; TClonesArray * muons = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("muons", &muons) ; TClonesArray * MET = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("MET", &MET) ; TClonesArray * tracks = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("tracks", &tracks) ; TClonesArray * tagJets = new TClonesArray ("TLorentzVector") ; TClonesArray * otherJets = new TClonesArray ("TLorentzVector") ; int EleId[100]; float IsolEleSumPt_VBF[100]; int nEle; int EleCharge[30]; tree->SetBranchAddress ("nEle", &nEle) ; tree->SetBranchAddress ("EleId",EleId ) ; tree->SetBranchAddress ("IsolEleSumPt_VBF",IsolEleSumPt_VBF ) ; tree->SetBranchAddress ("EleCharge",EleCharge ) ; float IsolMuTr[100]; int nMu ; int MuCharge[30]; tree->SetBranchAddress ("nMu", &nMu) ; tree->SetBranchAddress ("IsolMuTr",IsolMuTr ) ; tree->SetBranchAddress ("MuCharge", MuCharge) ; int IdEvent; tree->SetBranchAddress ("IdEvent", &IdEvent) ; int nentries = (int) tree->GetEntries () ; plots.passedJetAndLepNumberSelections = 0; plots.analyzed = 0; plots.analyzed_ee = 0; plots.analyzed_mumu = 0; plots.analyzed_tautau = 0; plots.analyzed_emu = 0; plots.analyzed_etau = 0; plots.analyzed_mutau = 0; plots.passedJetAndLepNumberSelections_ee = 0; plots.passedJetAndLepNumberSelections_mumu = 0; plots.passedJetAndLepNumberSelections_tautau = 0; plots.passedJetAndLepNumberSelections_emu = 0; plots.passedJetAndLepNumberSelections_etau = 0; plots.passedJetAndLepNumberSelections_mutau = 0; //PG loop over the events for (int evt = 0 ; evt < nentries ; ++evt) { tree->GetEntry (evt) ; tagJets -> Clear () ; otherJets -> Clear () ; //---- check if signal ---- if (if_signal && (IdEvent!=123 && IdEvent!=124)) continue; plots.analyzed++; //!---- MC ---- if (IdEvent==123 || IdEvent==124) { //---- VBF event ---- plots.v_decay_Channel_e = 0; plots.v_decay_Channel_mu = 0; plots.v_decay_Channel_tau = 0; for (int iGen = 0; iGen < genParticles->GetEntries() ; ++iGen){ TParticle* myparticle = (TParticle*) genParticles->At(iGen); if (abs(myparticle->GetPdgCode()) == 24) { //---- W Int_t mother1 = 0; mother1 = myparticle->GetMother(0); if (mother1 == 25) { //---- mother is higgs ---- for (int iDaughter = 0; iDaughter<2; iDaughter++){ if (abs(myparticle->GetDaughter(iDaughter)) == 11) {//---- W -> e plots.v_decay_Channel_e++; } if (abs(myparticle->GetDaughter(iDaughter)) == 13) {//---- W -> mu plots.v_decay_Channel_mu++; } if (abs(myparticle->GetDaughter(iDaughter)) == 15) {//---- W -> tau plots.v_decay_Channel_tau++; } } } } } } if (plots.v_decay_Channel_e == 2) plots.analyzed_ee++; if (plots.v_decay_Channel_mu == 2) plots.analyzed_mumu++; if (plots.v_decay_Channel_tau == 2) plots.analyzed_tautau++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_mu == 1) plots.analyzed_emu++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_tau == 1) plots.analyzed_etau++; if (plots.v_decay_Channel_mu == 1 && plots.v_decay_Channel_tau == 1) plots.analyzed_mutau++; int cutId = 0 ; plots.increase (cutId++) ; //AM 0 -> total number of events // std::cerr << "--- preambolo leptoni " << std::endl; std::vector<lepton> leptons ; //PG pour electrons into leptons collection //PG --------------------------------------- //PG loop over electrons for (int iele = 0; iele < electrons->GetEntries () ; ++iele) { TLorentzVector * theEle = (TLorentzVector*) (electrons->At (iele)) ; lepton dummy (theEle, 0, iele) ; leptons.push_back (dummy) ; } //PG loop over electrons //PG loop over muons for (int imu = 0 ; imu < nMu ; ++imu) { TLorentzVector * theMu = (TLorentzVector*) (muons->At (imu)) ; lepton dummy (theMu, 1, imu) ; leptons.push_back (dummy) ; } //PG loop over muons //PG this check is not necessary //PG if (leptons.size () < 2) continue ; // std::cerr << "--- inizia leptoni " << std::endl; //PG 2 LEPTONS //PG --------- /* applied after the leptons choice: in this case it is possible to differentiate the selections depending on the position of each lepton in the pt-sorting. the algorithm searches the first two most energetic candidates which satisfy the ID selections required for the first and second lepton respectively. Then check for channel analysis according to "g_LepLep" 0 == ee 1 == mumu 2 == emu 3 == mue pt ordered */ sort (leptons.rbegin (), leptons.rend (), lessThan ()) ; lepton primoLEP ; lepton secondoLEP ; double first_lepton_charge = 0; double second_lepton_charge = 0; int lepton_counter = 0; int electron_counter = 0; int muon_counter = 0; //PG find the first lepton int ilep = 0 ; for ( ; ilep < leptons.size () ; ++ilep) { if (leptons.at (ilep).m_flav == 0) //PG electron { //PG iso check bool eleIso = (IsolEleSumPt_VBF[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoElectron ; // 0.2 per il momento if (g_ISO1[0] == 1 && eleIso != 1) continue; //PG eleID check int eleID = EleId[leptons.at (ilep).m_index] ; if (g_ID1 == 100 && (eleID/100) != 1) continue; else if (g_ID1 == 10 && ((eleID%100)/10) != 1) continue; else if (g_ID1 == 1 && (eleID%10) != 1) continue; first_lepton_charge = EleCharge[leptons.at (ilep).m_index]; } else //PG muon { //PG iso check bool muIso = (IsolMuTr[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoMuon ; if (g_ISO1[1] == 1 && muIso != 1) continue; first_lepton_charge = MuCharge[leptons.at (ilep).m_index]; } primoLEP = leptons[ilep] ; lepton_counter++; if (leptons.at (ilep).m_flav == 0) electron_counter++; else muon_counter++; break ; } //PG find the first lepton //PG find the second lepton bool flag_secondoLEP = false; for (++ilep ; ilep < leptons.size () ; ++ilep) { if (leptons.at (ilep).m_flav == 0) //PG electron { //PG iso check bool eleIso = (IsolEleSumPt_VBF[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoElectron ; // 0.2 per il momento if (g_ISO2[0] == 1 && eleIso != 1) continue; //PG eleID check int eleID = EleId[leptons.at (ilep).m_index] ; if (g_ID2 == 100 && (eleID/100) != 1) continue; else if (g_ID2 == 10 && ((eleID%100)/10) != 1) continue; else if (g_ID2 == 1 && (eleID%10) != 1) continue; second_lepton_charge = EleCharge[leptons.at (ilep).m_index]; } else //PG muon { //PG iso check bool muIso = (IsolMuTr[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoMuon ; if (g_ISO2[1] == 1 && muIso != 1) continue; second_lepton_charge = MuCharge[leptons.at (ilep).m_index]; } if (!flag_secondoLEP) { secondoLEP = leptons[ilep] ; flag_secondoLEP = true; } if (leptons.at (ilep).m_kine->Pt () > 0) { if (leptons.at (ilep).m_flav == 0) electron_counter++; else muon_counter++; lepton_counter++; } } //PG find the second lepton //---- AM 3 --- 2 leptons after Id if (primoLEP.m_flav == -1 || secondoLEP.m_flav == -1) continue ; //---- AM 4 check for the two most transverse-energetic leptons have the right flavours plots.v_numLep = lepton_counter; plots.v_numEle = electron_counter; plots.v_numMu = muon_counter; if (primoLEP.m_flav == 0 && secondoLEP.m_flav == 0) plots.v_LepLep = 0 ; if (primoLEP.m_flav == 1 && secondoLEP.m_flav == 1) plots.v_LepLep = 1 ; if (primoLEP.m_flav == 0 && secondoLEP.m_flav == 1) plots.v_LepLep = 2 ; if (primoLEP.m_flav == 1 && secondoLEP.m_flav == 0) plots.v_LepLep = 3 ; plots.v_hardLEPPt = primoLEP.m_kine->Pt () ; //---- AM 5 pt_min of the most energetic lepton plots.v_softLEPPt = secondoLEP.m_kine->Pt () ; //---- AM 6 pt_min of the least energetic lepton plots.v_LEPDPhi = deltaPhi (primoLEP.m_kine->Phi (), secondoLEP.m_kine->Phi ()) ; //---- AM 7 Delta_phi_min between leptons plots.v_LEPDEta = deltaEta (primoLEP.m_kine->Eta (), secondoLEP.m_kine->Eta ()) ; plots.v_LEPDR = deltaR (primoLEP.m_kine->Phi (),primoLEP.m_kine->Eta (), secondoLEP.m_kine->Phi (), secondoLEP.m_kine->Eta ()) ; TLorentzVector sumLEP = *(primoLEP.m_kine) + *(secondoLEP.m_kine) ; plots.v_LEPMinv = sumLEP.M () ; //---- AM 9 MInv_min of leptons plots.v_LEPProdCharge = first_lepton_charge * second_lepton_charge ; plots.v_hardLEPCharge = first_lepton_charge ; plots.v_softLEPCharge = second_lepton_charge ; //PG MET //PG --- // std::cerr << "--- finito " << std::endl; TLorentzVector* met = ((TLorentzVector*) (MET->At(0))) ; //correct for muons for (int i = 0 ; i < nMu ; i++) { TLorentzVector * mu_v = (TLorentzVector*) (muons->At (i)) ; if (mu_v->Pt () > 3) { met->SetPx (met->Px () - mu_v->Px ()) ; met->SetPy (met->Py () - mu_v->Py ()) ; } } plots.v_MET = met->Pt () ; //---- AM 11 Met_min ----------------> Met correction ? // if (((TLorentzVector*) (MET->At (0)))->Pt () < g_METMin) continue ; plots.increase (cutId++) ; //PG 10 //PG Ztautau vetos //PG ------------- //PG the two electrons should not be opposite to each other // // TVector2 primoLEPT (primoLEP.m_kine->X (), primoLEP.m_kine->Y ()) ; // TVector2 secondoLEPT (secondoLEP.m_kine->X (), secondoLEP.m_kine->Y ()) ; // TVector2 METT (met->X (), met->Y ()) ; // // double Sum = METT * primoLEPT + METT * secondoLEPT / (1 + primoLEPT * secondoLEPT) ; // double Dif = METT * primoLEPT - METT * secondoLEPT / (1 - primoLEPT * secondoLEPT) ; // // TVector2 METT1 = 0.5 * (Sum + Dif) * primoLEPT ; // TVector2 METT2 = 0.5 * (Sum - Dif) * secondoLEPT ; // // double ptNu1 = METT1.Mod () / cos (primoLEP.m_kine->Theta ()) ; // double ptNu2 = METT2.Mod () / cos (secondoLEP.m_kine->Theta ()) ; plots.m_tree_selections->Fill(); plots.passedJetAndLepNumberSelections++; if (plots.v_decay_Channel_e == 2) plots.passedJetAndLepNumberSelections_ee++; if (plots.v_decay_Channel_mu == 2) plots.passedJetAndLepNumberSelections_mumu++; if (plots.v_decay_Channel_tau == 2) plots.passedJetAndLepNumberSelections_tautau++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_mu == 1) plots.passedJetAndLepNumberSelections_emu++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_tau == 1) plots.passedJetAndLepNumberSelections_etau++; if (plots.v_decay_Channel_mu == 1 && plots.v_decay_Channel_tau == 1) plots.passedJetAndLepNumberSelections_mutau++; } //PG loop over the events plots.m_efficiency->Fill(); plots.m_efficiency->Write(); plots.m_tree_selections->Write(); delete otherJets_temp ; delete tagJets ; delete otherJets ; delete electrons ; delete muons ; delete MET ; delete tracks ; return 0; }
bool DMCPeta::run() { resetUpdateEngine(); //estimator is ready to collect data Estimators->setCollectionMode(true); Estimators->start(nBlocks,true); Timer myclock; IndexType block = 0; IndexType numPtcls=W.getTotalNum(); RealType oneover2tau = 0.5/Tau; RealType sqrttau = std::sqrt(Tau); //temporary data to store differences ParticleSet::ParticlePos_t deltaR(numPtcls); ParticleSet::ParticleGradient_t G(numPtcls), dG(numPtcls); ParticleSet::ParticleLaplacian_t L(numPtcls), dL(numPtcls); CurrentStep = 0; typedef MCWalkerConfiguration::iterator WalkerIter_t; do // block { Mover->startBlock(nSteps); for(IndexType step=0; step< nSteps; step++, CurrentStep+=BranchInterval) { for(IndexType interval=0; interval<BranchInterval; ++interval) { for(WalkerIter_t it=W.begin();it != W.end(); ++it) { //MCWalkerConfiguration::WalkerData_t& w_buffer = *(W.DataSet[iwalker]); Walker_t& thisWalker(**it); Walker_t::Buffer_t& w_buffer(thisWalker.DataSet); W.R = thisWalker.R; w_buffer.rewind(); W.copyFromBuffer(w_buffer); Psi.copyFromBuffer(W,w_buffer); //create a 3N-Dimensional Gaussian with variance=1 makeGaussRandomWithEngine(deltaR,Random); int nAcceptTemp(0); int nRejectTemp(0); RealType eold(thisWalker.Properties(LOCALENERGY)); RealType enew(eold); RealType rr_proposed=0.0; RealType rr_accepted=0.0; //loop over particles for(int iat=0; iat<numPtcls; iat++) { PosType dr(sqrttau*deltaR[iat]+thisWalker.Drift[iat]); PosType newpos(W.makeMove(iat,dr)); RealType ratio=Psi.ratio(W,iat,dG,dL); RealType rr=dot(dr,dr); rr_proposed+=rr; if(branchEngine->phaseChanged(Psi.getPhaseDiff())) {//node crossing detected ++nRejectTemp; W.rejectMove(iat); Psi.rejectMove(iat); } else { G = W.G+dG; RealType logGf = -0.5*dot(deltaR[iat],deltaR[iat]); RealType scale=getDriftScale(Tau,G); dr = thisWalker.R[iat]-newpos-scale*real(G[iat]); RealType logGb = -oneover2tau*dot(dr,dr); RealType prob = std::min(1.0,ratio*ratio*std::exp(logGb-logGf)); if(Random() < prob) {//move is accepted ++nAcceptTemp; W.acceptMove(iat); Psi.acceptMove(W,iat); W.G = G; W.L += dL; assignDrift(scale,G,thisWalker.Drift); rr_accepted+=rr; } else { ++nRejectTemp; W.rejectMove(iat); Psi.rejectMove(iat); } } }//for(int iat=0; iat<NumPtcl; iat++) if(nAcceptTemp>0) {//need to overwrite the walker properties thisWalker.R = W.R; w_buffer.rewind(); W.copyToBuffer(w_buffer); //RealType psi = Psi.evaluate(W,w_buffer); RealType logpsi = Psi.evaluateLog(W,w_buffer); enew= H.evaluate(W); //thisWalker.resetProperty(std::log(abs(psi)),psi,enew,rr_accepted,rr_proposed,1.0); thisWalker.resetProperty(logpsi,Psi.getPhase(),enew,rr_accepted,rr_proposed,1.0 ); H.auxHevaluate(W,thisWalker); H.saveProperty(thisWalker.getPropertyBase()); } else { thisWalker.rejectedMove(); thisWalker.Age++; rr_accepted=0.0; enew=eold;//copy back old energy } thisWalker.Weight *= branchEngine->branchWeight(eold,enew); nAccept += nAcceptTemp; nReject += nRejectTemp; }//for(WalkerIter_t it=W.begin();it != W.end(); ++it) }//interval //calculate multiplicity based on the weights: see QMCUpdateBase::setMultiplicity Mover->setMultiplicity(W.begin(),W.end()); //time to branch: see SimpleFixedNodeBranch::branch branchEngine->branch(CurrentStep,W); if(storeConfigs && (CurrentStep%storeConfigs == 0)) { ForwardWalkingHistory.storeConfigsForForwardWalking(W); W.resetWalkerParents(); } }//steps ++block; Estimators->stopBlock(static_cast<RealType>(nAccept)/static_cast<RealType>(nAccept+nReject)); recordBlock(block); } while(block<nBlocks && myclock.elapsed()<MaxCPUSecs); Estimators->stop(); return finalize(block); }
void LiveSLAMWrapper::Loop() { std::list<visensor_node::visensor_imu>::reverse_iterator reverse_iterImu ; std::list<ImageMeasurement>::iterator pIter ; ros::Time imageTimeStamp ; cv::Mat image0 ; cv::Mat image1 ; ros::Rate r(1000.0); while ( nh.ok() ) { monoOdometry->tracking_mtx.lock(); bool tmpFlag = monoOdometry->lock_densetracking ; monoOdometry->tracking_mtx.unlock(); //printf("tmpFlag = %d\n", tmpFlag ) ; if ( tmpFlag == true ){ r.sleep() ; continue ; } image0_queue_mtx.lock(); image1_queue_mtx.lock(); imu_queue_mtx.lock(); pIter = pImage0Iter ; pIter++ ; if ( pIter == image0Buf.end() ){ image0_queue_mtx.unlock(); image1_queue_mtx.unlock(); imu_queue_mtx.unlock(); r.sleep() ; continue ; } imageTimeStamp = pIter->t ; pIter = pImage1Iter ; pIter++ ; if ( pIter == image1Buf.end() ){ image0_queue_mtx.unlock(); image1_queue_mtx.unlock(); imu_queue_mtx.unlock(); r.sleep() ; continue ; } if ( image1Buf.rbegin()->t < imageTimeStamp ) { image0_queue_mtx.unlock(); image1_queue_mtx.unlock(); imu_queue_mtx.unlock(); r.sleep() ; continue ; } reverse_iterImu = imuQueue.rbegin() ; // printf("%d %d\n", imuQueue.size() < 10, reverse_iterImu->header.stamp <= imageTimeStamp ) ; if ( imuQueue.size() < 1 || reverse_iterImu->header.stamp < imageTimeStamp ){ image0_queue_mtx.unlock(); image1_queue_mtx.unlock(); imu_queue_mtx.unlock(); r.sleep() ; continue ; } imu_queue_mtx.unlock(); while ( pImage1Iter->t < imageTimeStamp ){ pImage1Iter++ ; } pImage0Iter++ ; //std::cout << imageTimeStamp.toNSec() << "\n" ; //std::cout << "[dt-image] " << imageTimeStamp << std::endl ; //std::cout << "[dt-imu] " << reverse_iterImu->header.stamp << " " << imuQueue.size() << std::endl ; ros::Time preTime = imageTimeStamp ; //pImage1Iter++ ; image1 = pImage1Iter->image.clone(); image0 = pImage0Iter->image.clone(); image1_queue_mtx.unlock(); image0_queue_mtx.unlock(); imu_queue_mtx.lock(); Quaterniond q, dq ; q.setIdentity() ; while ( currentIMU_iter->header.stamp < imageTimeStamp ) { double pre_t = currentIMU_iter->header.stamp.toSec(); currentIMU_iter++ ; double next_t = currentIMU_iter->header.stamp.toSec(); double dt = next_t - pre_t ; //prediction for dense tracking dq.x() = currentIMU_iter->angular_velocity.x*dt*0.5 ; dq.y() = currentIMU_iter->angular_velocity.y*dt*0.5 ; dq.z() = currentIMU_iter->angular_velocity.z*dt*0.5 ; dq.w() = sqrt( 1 - SQ(dq.x()) * SQ(dq.y()) * SQ(dq.z()) ) ; q = (q * dq).normalized(); } imu_queue_mtx.unlock(); // process image //Util::displayImage("MyVideo", image.data); Matrix3d deltaR(q) ; //puts("444") ; // cv::imshow("img0", image0 ) ; // cv::imshow("img1", image1 ) ; // cv::waitKey(1) ; ++imageSeqNumber; assert(image0.elemSize() == 1); assert(image1.elemSize() == 1); assert(fx != 0 || fy != 0); // if(!isInitialized) // { // monoOdometry->insertFrame(imageSeqNumber, image1, imageTimeStamp, // Eigen::Matrix3d::Identity(), Eigen::Vector3d::Zero(), Eigen::Vector3d::Zero() ); // cv::Mat disparity, depth ; // monoOdometry->bm_(image1, image0, disparity, CV_32F); // calculateDepthImage(disparity, depth, 0.11, fx ); // monoOdometry->currentKeyFrame = monoOdometry->slidingWindow[0] ; // monoOdometry->currentKeyFrame->setDepthFromGroundTruth( (float*)depth.data ) ; // monoOdometry->currentKeyFrame->keyFrameFlag = true ; // monoOdometry->currentKeyFrame->cameraLinkList.clear() ; // monoOdometry->RefToFrame = Sophus::SE3() ; // isInitialized = true; // } // else if(isInitialized && monoOdometry != nullptr) // { monoOdometry->trackFrame(image0, imageSeqNumber, imageTimeStamp, deltaR, R_i_2_c, T_i_2_c ); // } } }
//!PG main function int selector (TChain * tree, histos & plots, int if_signal) { plots.v_Jet_1_Pt = -99; plots.v_Jet_2_Pt = -99; plots.v_Jet_3_Pt = -99; plots.v_Jet_4_Pt = -99; plots.v_Jet_5_Pt = -99; plots.v_Jet_6_Pt = -99; plots.v_Jet_1_x = -99; plots.v_Jet_2_x = -99; plots.v_Jet_3_x = -99; plots.v_Jet_4_x = -99; plots.v_Jet_5_x = -99; plots.v_Jet_6_x = -99; plots.v_Jet_1_y = -99; plots.v_Jet_2_y = -99; plots.v_Jet_3_y = -99; plots.v_Jet_4_y = -99; plots.v_Jet_5_y = -99; plots.v_Jet_6_y = -99; plots.v_Jet_1_z = -99; plots.v_Jet_2_z = -99; plots.v_Jet_3_z = -99; plots.v_Jet_4_z = -99; plots.v_Jet_5_z = -99; plots.v_Jet_6_z = -99; plots.v_Jet_1_e = -99; plots.v_Jet_2_e = -99; plots.v_Jet_3_e = -99; plots.v_Jet_4_e = -99; plots.v_Jet_5_e = -99; plots.v_Jet_6_e = -99; plots.v_Jet_1_eta = -99; plots.v_Jet_2_eta = -99; plots.v_Jet_3_eta = -99; plots.v_Jet_4_eta = -99; plots.v_Jet_5_eta = -99; plots.v_Jet_6_eta = -99; plots.v_Jet_1_phi = -99; plots.v_Jet_2_phi = -99; plots.v_Jet_3_phi = -99; plots.v_Jet_4_phi = -99; plots.v_Jet_5_phi = -99; plots.v_Jet_6_phi = -99; plots.v_Jet_1_DR = -99; plots.v_Jet_2_DR = -99; plots.v_Jet_3_DR = -99; plots.v_Jet_4_DR = -99; plots.v_Jet_5_DR = -99; plots.v_Jet_6_DR = -99; plots.v_numEle = -99; plots.v_numMu = -99; plots.v_numJets = -99; plots.v_totNumJets = -99; // TClonesArray * tagJets = new TClonesArray ("TLorentzVector") ; // tree->SetBranchAddress ("tagJets", &tagJets) ; TClonesArray * otherJets_temp = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress (g_KindOfJet.c_str(), &otherJets_temp) ; // tree->SetBranchAddress ("otherJets", &otherJets_temp) ; TClonesArray * electrons = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("electrons", &electrons) ; TClonesArray * muons = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("muons", &muons) ; TClonesArray * MET = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("MET", &MET) ; TClonesArray * tracks = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("tracks", &tracks) ; TClonesArray * tagJets = new TClonesArray ("TLorentzVector") ; TClonesArray * otherJets = new TClonesArray ("TLorentzVector") ; TClonesArray * HiggsParticle = new TClonesArray ("TParticle") ; tree->SetBranchAddress ("HiggsParticle", &HiggsParticle) ; int EleId[100]; float IsolEleSumPt_VBF[100]; int nEle; tree->SetBranchAddress ("nEle", &nEle) ; tree->SetBranchAddress ("EleId",EleId ) ; tree->SetBranchAddress ("IsolEleSumPt_VBF",IsolEleSumPt_VBF ) ; float IsolMuTr[100]; int nMu ; tree->SetBranchAddress ("nMu", &nMu) ; tree->SetBranchAddress ("IsolMuTr",IsolMuTr ) ; int IdEvent; tree->SetBranchAddress ("IdEvent", &IdEvent) ; int nentries = (int) tree->GetEntries () ; plots.passedJetAndLepNumberSelections = 0; plots.analyzed = 0; //PG loop over the events // std::cerr << " --- nentries = " << nentries << std::endl; // nentries = std::min(10000,nentries); // nentries = 10000; if (g_numEvents!= -1) nentries = std::min(g_numEvents,nentries); std::cerr << " --- nentries = " << nentries << std::endl; for (int evt = 0 ; evt < nentries ; ++evt) { if (!(evt%1000)) std::cerr << " --- evt = " << evt << std::endl; plots.v_Jet_1_Pt = -99; plots.v_Jet_2_Pt = -99; plots.v_Jet_3_Pt = -99; plots.v_Jet_4_Pt = -99; plots.v_Jet_5_Pt = -99; plots.v_Jet_6_Pt = -99; plots.v_Jet_7_Pt = -99; plots.v_Jet_8_Pt = -99; plots.v_Jet_1_x = -99; plots.v_Jet_2_x = -99; plots.v_Jet_3_x = -99; plots.v_Jet_4_x = -99; plots.v_Jet_5_x = -99; plots.v_Jet_6_x = -99; plots.v_Jet_7_x = -99; plots.v_Jet_8_x = -99; plots.v_Jet_1_y = -99; plots.v_Jet_2_y = -99; plots.v_Jet_3_y = -99; plots.v_Jet_4_y = -99; plots.v_Jet_5_y = -99; plots.v_Jet_6_y = -99; plots.v_Jet_7_y = -99; plots.v_Jet_8_y = -99; plots.v_Jet_1_z = -99; plots.v_Jet_2_z = -99; plots.v_Jet_3_z = -99; plots.v_Jet_4_z = -99; plots.v_Jet_5_z = -99; plots.v_Jet_6_z = -99; plots.v_Jet_7_z = -99; plots.v_Jet_8_z = -99; plots.v_Jet_1_e = -99; plots.v_Jet_2_e = -99; plots.v_Jet_3_e = -99; plots.v_Jet_4_e = -99; plots.v_Jet_5_e = -99; plots.v_Jet_6_e = -99; plots.v_Jet_7_e = -99; plots.v_Jet_8_e = -99; plots.v_Jet_1_eta = -99; plots.v_Jet_2_eta = -99; plots.v_Jet_3_eta = -99; plots.v_Jet_4_eta = -99; plots.v_Jet_5_eta = -99; plots.v_Jet_6_eta = -99; plots.v_Jet_7_eta = -99; plots.v_Jet_8_eta = -99; plots.v_Jet_1_phi = -99; plots.v_Jet_2_phi = -99; plots.v_Jet_3_phi = -99; plots.v_Jet_4_phi = -99; plots.v_Jet_5_phi = -99; plots.v_Jet_6_phi = -99; plots.v_Jet_7_phi = -99; plots.v_Jet_8_phi = -99; plots.v_Jet_1_DR = -99; plots.v_Jet_2_DR = -99; plots.v_Jet_3_DR = -99; plots.v_Jet_4_DR = -99; plots.v_Jet_5_DR = -99; plots.v_Jet_6_DR = -99; plots.v_Jet_7_DR = -99; plots.v_Jet_8_DR = -99; plots.v_numEle = -99; plots.v_numMu = -99; plots.v_numJets = -99; plots.v_totNumJets = -99; tree->GetEntry (evt) ; tagJets -> Clear () ; otherJets -> Clear () ; //---- check if signal ---- if (if_signal && (IdEvent!=123 && IdEvent!=124)) continue; plots.analyzed++; //---- MC data ---- std::vector<TLorentzVector*> MCJets ; TLorentzVector* MCJets_temp[6] ; int counter = 0; if (if_signal && (IdEvent==123 || IdEvent==124)){ for(int ii=0; ii<9; ii++){ // if (ii==0 || ii==1){ // if (ii!=0 && ii!=1 && ii!=2 && ii!=3 && ii!=6){ if (ii!=2 && ii!=3 && ii!=6){ TParticle* myparticle = (TParticle*) HiggsParticle->At(ii); // std::cerr << "pdg = " << ii << " = " << myparticle->GetPdgCode() << std::endl; MCJets_temp[counter] = new TLorentzVector; myparticle->Momentum(*(MCJets_temp[counter])); MCJets.push_back((MCJets_temp[counter])); counter++; } } } //---- find Tagging Jets ---- double m_jetPtMin = 15.; double m_jetEtaMax = 5.; double m_jetDEtaMin = -1; double m_jetMjjMin = -1; std::vector<myJet> goodJets ; // std::cerr << std::endl << std::endl << std::endl << std::endl << std::endl; for (int l=0; l<otherJets_temp->GetEntries (); l++ ){ TLorentzVector* jet_temp = (TLorentzVector*) otherJets_temp->At(l); if (jet_temp->Pt()<m_jetPtMin) continue; //---- Eta max threshold ---- if (jet_temp->Eta()>m_jetEtaMax) continue; //---- pt min threshold ---- myJet dummy (jet_temp, 0, 0) ; goodJets.push_back (dummy) ; } // for (int gg=0; gg<goodJets.size(); gg++ ) std::cerr << " goodJets[" << gg << "] = " << &(goodJets.at(gg)) << std::endl; sort (goodJets.rbegin (), goodJets.rend (), lessThan ()) ; std::vector<std::pair<TLorentzVector*,TLorentzVector*> > Vect_PairQuark_RecoJet; std::vector<double> Map2D_PairQuark_RecoJet; int counter_map = 0; for (int rr=0; rr<std::min(g_numJet,static_cast<int>(goodJets.size())); rr++ ){ //--- loop over recoJets ---- for (int k=0; k<MCJets.size(); k++ ){ //--- loop over quarks ---- TLorentzVector* quark_temp = MCJets.at(k); TLorentzVector* jet_temp = goodJets.at(rr).m_kine; double DR = ROOT::Math::VectorUtil::DeltaR(quark_temp->BoostVector(),jet_temp->BoostVector()); Map2D_PairQuark_RecoJet.push_back(DR); counter_map++; } //--- end loop over recoJet ---- } //--- end loop over quarks ---- int selected_pair_jet[6] ; int selected_pair_quark[6] ; for (int jj=0; jj<MCJets.size(); jj++ ){ selected_pair_jet[jj] = -1; selected_pair_quark[jj] = -1; } for (int jj=0; jj<MCJets.size(); jj++ ){ double DR_min = 1000; counter_map = 0; int temp_selected_pair_jet = -1; int temp_selected_pair_quark = -1; for (int rr=0; rr<std::min(g_numJet,static_cast<int>(goodJets.size())); rr++ ){ //--- loop over recoJets ---- for (int k=0; k<MCJets.size(); k++ ){ //--- loop over quarks ---- bool already_done = false; for (int qq=0; qq<MCJets.size(); qq++) { if ((selected_pair_jet[qq] == rr) || (selected_pair_quark[qq] == k)) already_done = true; } if (!already_done){ double DR_temp = Map2D_PairQuark_RecoJet.at(counter_map); if (DR_temp<DR_min) { DR_min = DR_temp; temp_selected_pair_jet = rr; temp_selected_pair_quark = k; } } counter_map++; } } selected_pair_jet[jj] = temp_selected_pair_jet; selected_pair_quark[jj] = temp_selected_pair_quark; } for (int rr=0; rr<std::min(g_numJet,static_cast<int>(goodJets.size())); rr++ ){ //--- loop over recoJets ---- for (int k=0; k<MCJets.size(); k++ ){ //--- loop over quarks ---- bool used_one = false; for (int qq=0; qq<MCJets.size(); qq++) { if ((selected_pair_jet[qq] == rr) && (selected_pair_quark[qq] == k)) used_one = true; } if (used_one){ TLorentzVector* quark_temp = MCJets.at(k); TLorentzVector* jet_temp = goodJets.at(rr).m_kine; std::pair<TLorentzVector*,TLorentzVector*> PairQuark_RecoJet(quark_temp,jet_temp); Vect_PairQuark_RecoJet.push_back(PairQuark_RecoJet); } } //--- end loop over recoJet ---- } //--- end loop over quarks ---- for (int iJet=0; iJet<std::min(g_numJet,static_cast<int>(goodJets.size())); iJet++){ double minDR = -1000; double eta_reco_temp = goodJets.at (iJet).m_kine->Eta () ; double phi_reco_temp = goodJets.at (iJet).m_kine->Phi () ; for (int pp=0; pp<static_cast<int>(Vect_PairQuark_RecoJet.size()); pp++ ){ double eta_1 = Vect_PairQuark_RecoJet.at(pp).second->Eta(); double phi_1 = Vect_PairQuark_RecoJet.at(pp).second->Phi(); double DR_temp = deltaR(phi_1,eta_1,phi_reco_temp,eta_reco_temp); if (DR_temp<0.001) { double eta_2 = Vect_PairQuark_RecoJet.at(pp).first->Eta(); double phi_2 = Vect_PairQuark_RecoJet.at(pp).first->Phi(); minDR = deltaR(phi_1,eta_1,phi_2,eta_2); break; } } if (iJet==0) { plots.v_Jet_1_Pt = goodJets.at (iJet).m_kine->Pt () ; plots.v_Jet_1_x = goodJets.at (iJet).m_kine->X () ; plots.v_Jet_1_y = goodJets.at (iJet).m_kine->Y () ; plots.v_Jet_1_z = goodJets.at (iJet).m_kine->Z () ; plots.v_Jet_1_eta = goodJets.at (iJet).m_kine->Eta () ; plots.v_Jet_1_phi = goodJets.at (iJet).m_kine->Phi () ; plots.v_Jet_1_DR = minDR; } if (iJet==1) { plots.v_Jet_2_Pt = goodJets.at (iJet).m_kine->Pt () ; plots.v_Jet_2_x = goodJets.at (iJet).m_kine->X () ; plots.v_Jet_2_y = goodJets.at (iJet).m_kine->Y () ; plots.v_Jet_2_z = goodJets.at (iJet).m_kine->Z () ; plots.v_Jet_2_eta = goodJets.at (iJet).m_kine->Eta () ; plots.v_Jet_2_phi = goodJets.at (iJet).m_kine->Phi () ; plots.v_Jet_2_DR = minDR; } if (iJet==2) { plots.v_Jet_3_Pt = goodJets.at (iJet).m_kine->Pt () ; plots.v_Jet_3_x = goodJets.at (iJet).m_kine->X () ; plots.v_Jet_3_y = goodJets.at (iJet).m_kine->Y () ; plots.v_Jet_3_z = goodJets.at (iJet).m_kine->Z () ; plots.v_Jet_3_eta = goodJets.at (iJet).m_kine->Eta () ; plots.v_Jet_3_phi = goodJets.at (iJet).m_kine->Phi () ; plots.v_Jet_3_DR = minDR; } if (iJet==3) { plots.v_Jet_4_Pt = goodJets.at (iJet).m_kine->Pt () ; plots.v_Jet_4_x = goodJets.at (iJet).m_kine->X () ; plots.v_Jet_4_y = goodJets.at (iJet).m_kine->Y () ; plots.v_Jet_4_z = goodJets.at (iJet).m_kine->Z () ; plots.v_Jet_4_eta = goodJets.at (iJet).m_kine->Eta () ; plots.v_Jet_4_phi = goodJets.at (iJet).m_kine->Phi () ; plots.v_Jet_4_DR = minDR; } if (iJet==4) { plots.v_Jet_5_Pt = goodJets.at (iJet).m_kine->Pt () ; plots.v_Jet_5_x = goodJets.at (iJet).m_kine->X () ; plots.v_Jet_5_y = goodJets.at (iJet).m_kine->Y () ; plots.v_Jet_5_z = goodJets.at (iJet).m_kine->Z () ; plots.v_Jet_5_eta = goodJets.at (iJet).m_kine->Eta () ; plots.v_Jet_5_phi = goodJets.at (iJet).m_kine->Phi () ; plots.v_Jet_5_DR = minDR; } if (iJet==5) { plots.v_Jet_6_Pt = goodJets.at (iJet).m_kine->Pt () ; plots.v_Jet_6_x = goodJets.at (iJet).m_kine->X () ; plots.v_Jet_6_y = goodJets.at (iJet).m_kine->Y () ; plots.v_Jet_6_z = goodJets.at (iJet).m_kine->Z () ; plots.v_Jet_6_eta = goodJets.at (iJet).m_kine->Eta () ; plots.v_Jet_6_phi = goodJets.at (iJet).m_kine->Phi () ; plots.v_Jet_6_DR = minDR; } if (iJet==6) { plots.v_Jet_7_Pt = goodJets.at (iJet).m_kine->Pt () ; plots.v_Jet_7_x = goodJets.at (iJet).m_kine->X () ; plots.v_Jet_7_y = goodJets.at (iJet).m_kine->Y () ; plots.v_Jet_7_z = goodJets.at (iJet).m_kine->Z () ; plots.v_Jet_7_eta = goodJets.at (iJet).m_kine->Eta () ; plots.v_Jet_7_phi = goodJets.at (iJet).m_kine->Phi () ; plots.v_Jet_7_DR = minDR; } if (iJet==7) { plots.v_Jet_8_Pt = goodJets.at (iJet).m_kine->Pt () ; plots.v_Jet_8_x = goodJets.at (iJet).m_kine->X () ; plots.v_Jet_8_y = goodJets.at (iJet).m_kine->Y () ; plots.v_Jet_8_z = goodJets.at (iJet).m_kine->Z () ; plots.v_Jet_8_eta = goodJets.at (iJet).m_kine->Eta () ; plots.v_Jet_8_phi = goodJets.at (iJet).m_kine->Phi () ; plots.v_Jet_8_DR = minDR; } } int numJets = goodJets.size(); plots.v_numJets = numJets; plots.v_totNumJets = static_cast<double>(otherJets_temp->GetEntries ()); //---- leptons ---- plots.v_numEle = 0; plots.v_numMu = 0; std::vector<lepton> leptons ; //---- AM ---- loop over electrons for (int iele = 0; iele < electrons->GetEntries () ; ++iele) { TLorentzVector * theEle = (TLorentzVector*) (electrons->At (iele)) ; lepton dummy (theEle, 0, iele) ; leptons.push_back (dummy) ; } //---- AM ---- loop over muons for (int imu = 0 ; imu < nMu ; ++imu) { TLorentzVector * theMu = (TLorentzVector*) (muons->At (imu)) ; lepton dummy (theMu, 1, imu) ; leptons.push_back (dummy) ; } for (int ilep=0 ; ilep < leptons.size () ; ++ilep){ if (leptons.at (ilep).m_flav == 0) {//PG electron plots.v_numEle += 1; } if (leptons.at (ilep).m_flav == 1) {//PG muon plots.v_numMu += 1; } } plots.m_tree_selections->Fill(); if (numJets >=6 ) plots.passedJetAndLepNumberSelections++; for (int hh=0; hh<counter; hh++) delete MCJets_temp[hh]; } //PG loop over the events // std::cerr << "---- Finishes ----" << std::endl; g_OutputFile->cd(0); plots.m_efficiency->Fill(); plots.m_efficiency->Write(); plots.m_tree_selections->Write(); // std::cerr << "---- Written ----" << std::endl; delete otherJets_temp ; delete tagJets ; delete otherJets ; delete electrons ; delete muons ; delete MET ; delete tracks ; // std::cerr << "---- Deleted ----" << std::endl; return 0; }
// Use bundle adjustment to compute global alignment from initial // alignment. int bundleAdjust(const vector<FeatureSet> &fs, MotionModel m, float f, const vector< pair<int,int> >& WH, const AlignMatrix &am, vector<CTransform3x3> &ms, int bundleAdjustIters) { int n = ms.size(); int nEqs = 0; double lastTotalError = 0; double lambda = 1; CVector3 p,q; vector<CTransform3x3> msTemp(n); // count the total number of inliers for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { nEqs += 3*am[i][j].inliers.size(); } } int width, height; // compute the initial total error for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { int s = am[i][j].inliers.size(); for (int k=0; k<s; k++) { int index1 = am[i][j].inliers[k]; int index2 = am[i][j].matches[index1].id - 1; width = WH[i].first; height = WH[i].second; p[0] = fs[i][index1].x - (width/2.0); p[1] = fs[i][index1].y - (height/2.0); p[2] = f; width = WH[j].first; height = WH[j].second; q[0] = fs[j][index2].x - (width/2.0); q[1] = fs[j][index2].y - (height/2.0); q[2] = f; p = ms[i].Transpose() * p.Normalize(); q = ms[j].Transpose() * q.Normalize(); lastTotalError += pow(p[0]-q[0],2); lastTotalError += pow(p[1]-q[1],2); lastTotalError += pow(p[2]-q[2],2); } } } printf("initial error %f\n", f*sqrt(3*lastTotalError/nEqs)); // create the least squares matrices matrix A(nEqs); for (int i=0; i<nEqs; i++) { A[i].resize(3*n); for (int j=0; j<3*n; j++) { A[i][j] = 0; } } vector<double> b(nEqs); for (int iter=0; iter<bundleAdjustIters; iter++) { printf("performing iteration %d of bundle adjustment, ", iter); int currentEq = 0; double totalError = 0; // clear the A matrix for (int i=0; i<nEqs; i++) for (int j=0; j<3*n; j++) A[i][j] = 0; // fill in the entries for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { int s = am[i][j].inliers.size(); for (int k=0; k<s; k++) { int index1 = am[i][j].inliers[k]; int index2 = am[i][j].matches[index1].id - 1; int var1 = 3*i; int var2 = 3*j; // BEGIN TODO // fill in the three equations for this match // // that is, fill in the entries for the rows // A[currentEq], A[currentEq+1], and A[currentEq+2] // // hint: only columns var1, var1+1, var1+2, and // columns var2, var2+1, var2+2 will be nonzero width = WH[i].first; height = WH[i].second; p[0] = fs[i][index1].x - (width/2.0); p[1] = fs[i][index1].y - (height/2.0); p[2] = f; width = WH[j].first; height = WH[j].second; q[0] = fs[j][index2].x - (width/2.0); q[1] = fs[j][index2].y - (height/2.0); q[2] = f; p = ms[i].Transpose() * p; q = ms[j].Transpose() * q; A[currentEq][var1]=0; A[currentEq][var1+1]=-p[2]; A[currentEq][var1+2]=p[1]; A[currentEq+1][var1]=p[2]; A[currentEq+1][var1+1]=0; A[currentEq+1][var1+2]=-p[0]; A[currentEq+2][var1]=-p[1]; A[currentEq+2][var1+1]=p[0]; A[currentEq+2][var1+2]=0; for(int tmpn = 0; tmpn < 3; tmpn++) q[tmpn] = -q[tmpn]; A[currentEq][var2]=0; A[currentEq][var2+1]=-q[2]; A[currentEq][var2+2]=q[1]; A[currentEq+1][var2]=q[2]; A[currentEq+1][var2+1]=0; A[currentEq+1][var2+2]=-q[0]; A[currentEq+2][var2]=-q[1]; A[currentEq+2][var2+1]=q[0]; A[currentEq+2][var2+2]=0; for(int tmpn = 0; tmpn < 3; tmpn++) b[currentEq+tmpn] = p[tmpn] + q[tmpn]; // END TODO currentEq += 3; } } } // solve the system of equations vector<double> x; least_squares(A,b,x,lambda); // update the rotation matrices for (int i=0; i<n; i++) { double wx = x[3*i+0]; double wy = x[3*i+1]; double wz = x[3*i+2]; // BEGIN TODO // update the ith rotation matrix // and store it in msTemp[i] // // you'll need to use the Rodriguez rule from the slides CTransform3x3 I, deltaR(0); deltaR[0][1]=-wz; deltaR[0][2]=wy; deltaR[1][0]=wz; deltaR[1][2]=-wx; deltaR[2][0]=-wy; deltaR[2][1]=wx; msTemp[i]=ms[i] * (I + deltaR); // END TODO } // compute the new total error for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { int s = am[i][j].inliers.size(); for (int k=0; k<s; k++) { int index1 = am[i][j].inliers[k]; int index2 = am[i][j].matches[index1].id - 1; width = WH[i].first; height = WH[i].second; p[0] = fs[i][index1].x - (width/2.0); p[1] = fs[i][index1].y - (height/2.0); p[2] = f; width = WH[j].first; height = WH[j].second; q[0] = fs[j][index2].x - (width/2.0); q[1] = fs[j][index2].y - (height/2.0); q[2] = f; p = msTemp[i].Transpose() * p.Normalize(); q = msTemp[j].Transpose() * q.Normalize(); totalError += pow(p[0]-q[0],2); totalError += pow(p[1]-q[1],2); totalError += pow(p[2]-q[2],2); } } } if (totalError > lastTotalError) { // error increased, don't use new transformations lambda *= 10; printf("error increased to %f, increasing lambda to %f\n", f*sqrt(3*totalError/nEqs), lambda); } else if (totalError < lastTotalError) { // error decreased, use new transformations lambda /= 10; ms = msTemp; lastTotalError = totalError; printf("error decreased to %f, decreasing lambda to %f\n", f*sqrt(3*totalError/nEqs), lambda); } else { // error converged, we can stop printf("error converged at %f\n", f*sqrt(3*totalError/nEqs)); break; } } return 0; }
void readNtuplesPostfilter_forAN(TString inputfilename="results.root", int sig=Sig::Prompt, int filt=filter::L3, std::string effmeasured="IterL3_NOHP_NOL1"){ bool doingL1 = (filt==filter::L1); TFile* outfile = TFile::Open(Form("%s_efficiency_post.root", effmeasured.c_str()),"RECREATE"); std::cout << "output file: " << outfile -> GetName() << std::endl; //Create histograms TH1F* dimuon_mass = new TH1F("h_dimuon_mass" ,"dimuon_mass" , 1500, 0, 150 ); TH1F* tagiso = new TH1F("h_tagiso" ,"tagiso" , 100, 0, 1 ); TH1F* tagMuonPt = new TH1F("h_tagMuonPt" ,"tagMuonPt" , 150, 0, 150 ); TH1F* nvtx_event = new TH1F("h_nvtx_event" ,"nvtx_event" , 60, 0, 60 ); TEfficiency* muonPt_barrel = new TEfficiency("muonPt_barrel" ,"muonPt_barrel" , 16, pt_bins ); TEfficiency* muonPt_endcap = new TEfficiency("muonPt_endcap" ,"muonPt_endcap" , 16, pt_bins ); TEfficiency* muonPt = new TEfficiency("muonPt" ,"muonPt" , 16, pt_bins ); TEfficiency* muonPtTurnOn = new TEfficiency("muonPtTurnOn" ,"muonPtTurnOn" , 16, pt_bins ); TEfficiency* muonEta = new TEfficiency("muonEta" ,"muonEta" , 15, eta_bins ); TEfficiency* muonPhi = new TEfficiency("muonPhi" ,"muonPhi" , 20, -3.2, 3.2); TEfficiency* muonEff = new TEfficiency("muonEff" ,"muonEff" , 1, 0., 1.0); TEfficiency* muonDeltaR = new TEfficiency("muonDeltaR" ,"muonDeltaR" , 30, 0., 3.0); TEfficiency* muonDeltaPhi = new TEfficiency("muonDeltaPhi" ,"muonDeltaPhi" , 30, 0., 3.2); // GLOBAL QUANTITIES// TEfficiency* muonchi2 = new TEfficiency("muonchi2" , "muonchi2" , 60, 0., 7.); TEfficiency* muondxy = new TEfficiency("muondxy" , "muondxy" , 100, -0.3, 0.3); TEfficiency* muondz = new TEfficiency("muondz" , "muondz" , 10, dz_bins); TEfficiency* muonPixHit = new TEfficiency("muonPixHit" , "muonPixHit" , 20, -0.5,19.5); TEfficiency* muonLayHit = new TEfficiency("muonLayHit" , "muonLayHit" , 16, 2.5,18.5); TEfficiency* muonPixLay = new TEfficiency("muonPixLay" , "muonPixLay" , 7, -0.5, 6.5); TEfficiency* muoninnerPt = new TEfficiency("muoninnerPt" , "muoninnerPt" , 16, pt_bins ); TEfficiency* muoninnerEta = new TEfficiency("muoninnerEta" , "muoninnerEta" , 15, eta_bins); TEfficiency* muoninnerPhi = new TEfficiency("muoninnerPhi" , "muoninnerPhi" , 20, -3.2, 3.2); TEfficiency* failingMuonPt = new TEfficiency("failingMuonPt" ,"failingMuonPt" , 16, pt_bins ); TEfficiency* failingMuonEta = new TEfficiency("failingMuonEta" ,"failingMuonEta" , 15, eta_bins ); TEfficiency* failingMuonPhi = new TEfficiency("failingMuonPhi" ,"failingMuonPhi" , 20, -3.2, 3.2); TEfficiency* failingMuonEff = new TEfficiency("failingMuonEff" ,"failingMuonEff" , 1 , 0., 1.0); TH1F* PassingProbePt = new TH1F("h_PassingProbePt" ,"PassingMuonPt" , 16, pt_bins ); TH1F* PassingProbeEta = new TH1F("h_PassingProbeEta" ,"PassingMuonEta" , 15, eta_bins ); TH1F* PassingProbePhi = new TH1F("h_PassingProbePhi" ,"PassingMuonPhi" , 20, -3.2, 3.2); TH1F* PassingProbeMll = new TH1F("h_PassingProbeMll" ,"PassingMuonMll" , 20, 86., 96.); TH1F* FailingProbePt = new TH1F("h_FailingProbePt" ,"FailingMuonPt" , 16, pt_bins ); TH1F* FailingProbeEta = new TH1F("h_FailingProbeEta" ,"FailingMuonEta" , 15, eta_bins ); TH1F* FailingProbePhi = new TH1F("h_FailingProbePhi" ,"FailingMuonPhi" , 20, -3.2, 3.2); TH1F* FailingProbeMll = new TH1F("h_FailingProbeMll" ,"FailingMuonMll" , 20, 86., 96.); // di-muon efficiencies TEfficiency* diMuonPt = new TEfficiency("diMuonPt" ,"diMuonPt" , 16, pt_bins , 16, pt_bins ); TEfficiency* diMuonEta = new TEfficiency("diMuonEta" ,"diMuonEta" , 15, eta_bins , 15, eta_bins ); TEfficiency* diMuonPhi = new TEfficiency("diMuonPhi" ,"diMuonPhi" , 20, -3.2, 3.2 , 20, -3.2, 3.2); TEfficiency* diMuonEff = new TEfficiency("diMuonEff" ,"diMuonEff" , 1, 0., 1.0); TEfficiency* diMuonDeltaR = new TEfficiency("diMuonDeltaR" ,"diMuonDeltaR" , 30, 0., 3.0); TEfficiency* diMuonLeadPt = new TEfficiency("diMuonLeadPt" ,"diMuonLeadPt" , 16, pt_bins ); TEfficiency* diMuonLeadEta = new TEfficiency("diMuonLeadEta" ,"diMuonLeadEta" , 15, eta_bins ); TEfficiency* diMuonLeadPhi = new TEfficiency("diMuonLeadPhi" ,"diMuonLeadPhi" , 20, -3.2, 3.2); TEfficiency* diMuonTrailPt = new TEfficiency("diMuonTrailPt" ,"diMuonTrailPt" , 16, pt_bins ); TEfficiency* diMuonTrailEta = new TEfficiency("diMuonTrailEta","diMuonTrailEta" , 15, eta_bins ); TEfficiency* diMuonTrailPhi = new TEfficiency("diMuonTrailPhi","diMuonTrailPhi" , 20, -3.2, 3.2); TEfficiency* nvtx = new TEfficiency("nvtx" ,"nvtx" , 60, 0, 60); TEfficiency* nvtx_barrel = new TEfficiency("nvtx_barrel" ,"nvtx_barrel" , 60, 0, 60); TEfficiency* nvtx_endcap = new TEfficiency("nvtx_endcap" ,"nvtx_endcap" , 60, 0, 60); TFile* inputfile = TFile::Open(inputfilename, "READ"); std::cout << "input file: " << inputfile -> GetName() << std::endl; TTree *tree = (TTree*) inputfile -> Get("muonNtuples/muonTree"); if (!tree) { std::cout << " *** tree not found *** " << std::endl; return; } MuonEvent* ev = new MuonEvent(); TBranch* evBranch = tree->GetBranch("event"); evBranch -> SetAddress(&ev); int nentries = tree->GetEntriesFast(); std::cout << "Number of entries = " << nentries << std::endl; std::string theprobefilter = getProbeFilter(sig); std::string thepassfilter = getPassFilter(sig,filt); offlinePtCut = getLeadingPtCut(sig); float ptcut1 = getLeadingPtCut(sig); float ptcut2 = getTrailingPtCut(sig); for (Int_t eventNo=0; eventNo < nentries; eventNo++) { Int_t IgetEvent = tree -> GetEvent(eventNo); printProgBar((int)(eventNo*100./nentries)); unsigned int nmuons = ev->muons.size(); if (nmuons < 2) continue; unsigned int nhltmuons = ev->hltmuons.size(); // if (!ev-> hltTag.find(hltname)) continue; nvtx_event-> Fill( ev -> nVtx ); for (int imu = 0; imu < nmuons; imu++){ // select the tag muon if (! selectTagMuon(ev -> muons.at(imu), tagiso)) continue; if (! matchMuon(ev -> muons.at(imu), ev -> hltTag.objects, isofilterTag)) continue; tagMuonPt -> Fill ( ev -> muons.at(imu).pt) ; for (int jmu = 0; jmu < nmuons; jmu++){ bool pass = false; // select the probe muon if (!selectProbeMuon(ev -> muons.at(jmu), ev -> muons.at(imu), dimuon_mass)) continue; // match probe muon to filter if (!doingL1 && !(matchMuon(ev -> muons.at(jmu), ev -> hlt.objects, theprobefilter))) continue; if (matchMuon(ev -> muons.at(jmu), ev -> hlt.objects, thepassfilter)) pass = true; muonPtTurnOn -> Fill( pass, ev -> muons.at(jmu).pt ); if (ev -> muons.at(jmu).pt < offlinePtCut) continue; TLorentzVector mu1, mu2; mu1.SetPtEtaPhiM (ev->muons.at(imu).pt,ev->muons.at(imu).eta,ev->muons.at(imu).phi, muonmass); mu2.SetPtEtaPhiM (ev->muons.at(jmu).pt,ev->muons.at(jmu).eta,ev->muons.at(jmu).phi, muonmass); double mumumass = (mu1 + mu2).M(); double DeltaR = mu1.DeltaR(mu2); double DeltaPhi = mu1.DeltaPhi(mu2); if (pass) { PassingProbePt -> Fill( ev -> muons.at(jmu).pt ); PassingProbeEta -> Fill( ev -> muons.at(jmu).eta ); PassingProbePhi -> Fill( ev -> muons.at(jmu).phi ); PassingProbeMll -> Fill( mumumass ); } else { FailingProbePt -> Fill( ev -> muons.at(jmu).pt ); FailingProbeEta -> Fill( ev -> muons.at(jmu).eta ); FailingProbePhi -> Fill( ev -> muons.at(jmu).phi ); FailingProbeMll -> Fill( mumumass ); } muonPt -> Fill( pass, ev -> muons.at(jmu).pt ); muonEta -> Fill( pass, ev -> muons.at(jmu).eta); muonPhi -> Fill( pass, ev -> muons.at(jmu).phi); muonEff -> Fill( pass, 0.5 ); muoninnerPt -> Fill( pass, ev -> muons.at(jmu).innerpt); muoninnerEta -> Fill( pass, ev -> muons.at(jmu).innereta); muoninnerPhi -> Fill( pass, ev -> muons.at(jmu).innerphi); muonchi2 -> Fill( pass, ev -> muons.at(jmu).innerchi2 ); muondxy -> Fill( pass, ev -> muons.at(jmu).innerdxy); muondz -> Fill( pass, ev -> muons.at(jmu).innerdz); muonPixHit -> Fill( pass, ev -> muons.at(jmu).innerpixelHits); muonLayHit -> Fill( pass, ev -> muons.at(jmu).innerlayerHits); muonPixLay -> Fill( pass, ev -> muons.at(jmu).innerpixelLayers); failingMuonPt -> Fill( !pass, ev->muons.at(jmu).pt ); failingMuonEta -> Fill( !pass, ev->muons.at(jmu).eta); failingMuonPhi -> Fill( !pass, ev->muons.at(jmu).phi); failingMuonEff -> Fill( !pass, 0.5 ); } // nmuons } /// NOW FOR DIMUONS: for (int imu = 0; imu < nmuons; imu++){ if (!selectMuon(ev -> muons.at(imu))) continue; // pass L1: if (!doingL1 && !(matchMuon(ev -> muons.at(imu), ev -> hlt.objects, theprobefilter))) continue; for (int jmu = imu+1; jmu < nmuons; jmu++){ if (!selectMuon(ev -> muons.at(jmu))) continue; if (!doingL1 && !(matchMuon(ev -> muons.at(jmu), ev -> hlt.objects, theprobefilter))) continue; // both should pass the L1 filter! bool pass = false; double DeltaR = deltaR(ev->muons.at(imu).eta,ev->muons.at(imu).phi,ev->muons.at(jmu).eta,ev->muons.at(jmu).phi); diMuonPt -> Fill( pass, ev->muons.at(imu).pt , ev->muons.at(jmu).pt ); diMuonLeadPt -> Fill( pass, ev->muons.at(imu).pt ); diMuonTrailPt -> Fill( pass, ev->muons.at(jmu).pt ); if (ev->muons.at(imu).pt < ptcut1) continue; if (ev->muons.at(jmu).pt < ptcut2) continue; diMuonEta -> Fill( pass, ev->muons.at(imu).eta, ev->muons.at(jmu).eta ); diMuonPhi -> Fill( pass, ev->muons.at(imu).phi, ev->muons.at(jmu).phi ); diMuonDeltaR -> Fill( pass, DeltaR); diMuonEff -> Fill( pass, 0.5); diMuonLeadEta -> Fill( pass, ev->muons.at(imu).eta ); diMuonTrailEta -> Fill( pass, ev->muons.at(jmu).eta ); diMuonLeadPhi -> Fill( pass, ev->muons.at(imu).phi ); diMuonTrailPhi -> Fill( pass, ev->muons.at(jmu).phi ); } } } //Writing the histograms in a file. outfile -> cd(); tagMuonPt -> Write(); muonPt -> Write(); muonPtTurnOn -> Write(); muonEta -> Write(); muonPhi -> Write(); muonEff -> Write(); muonDeltaR -> Write(); muonDeltaPhi -> Write(); muonchi2 -> Write(); muondxy -> Write(); muondz -> Write(); muonPixHit -> Write(); muonLayHit -> Write(); muonPixLay -> Write(); muoninnerPt -> Write(); muoninnerEta -> Write(); muoninnerPhi -> Write(); failingMuonPt -> Write(); failingMuonEta -> Write(); failingMuonPhi -> Write(); failingMuonEff -> Write(); PassingProbePt -> Write(); PassingProbeEta -> Write(); PassingProbePhi -> Write(); PassingProbeMll -> Write(); FailingProbePt -> Write(); FailingProbeEta -> Write(); FailingProbePhi -> Write(); FailingProbeMll -> Write(); /// Per-event (di-muon) efficiency. diMuonPt -> Write(); diMuonEta -> Write(); diMuonPhi -> Write(); diMuonDeltaR -> Write(); diMuonLeadPt -> Write(); diMuonLeadEta -> Write(); diMuonLeadPhi -> Write(); diMuonTrailPt -> Write(); diMuonTrailEta -> Write(); diMuonTrailPhi -> Write(); nvtx_event -> Write(); nvtx -> Write(); dimuon_mass -> Write(); tagiso -> Write(); outfile -> Close(); return; }
Bool_t TagAndProbe::Process(Long64_t entry) { // std::cout<<"----------------------"<<std::endl; resetValues(); fChain->GetTree()->GetEntry(entry); if(applyFilters_ && !FiltersPass() ) return kTRUE; if(HT < minHT_ && NJets<minNJets_) return kTRUE; if(ProbeIsoMuonNum>0 && MuIso_minDeltaPhiN>minDeltaPhiN_) { if(TagIsoMuonNum!=1) std::cout<<"Error this should never happen no tag iso muon found but some probe!!!!!"<<std::endl; bool matchTag=false; if(truthMatching_) { for(unsigned int ii=0; ii< GenMuNum; ii++) { // std::cout<<"DelatR lep["<<ii<<"]: "<<deltaR(GenMuEta[ii],GenMuPhi[ii],TagIsoMuonEta[0],TagIsoMuonPhi[0])<<" with pt gen: "<<GenMuPt[ii]<<" and reco pt: "<<TagIsoMuonPt[0]<<std::endl; if(deltaR(GenMuEta[ii],GenMuPhi[ii],TagIsoMuonEta[0],TagIsoMuonPhi[0])<maxDeltaRGenToRecoMu_ ) { if(matchTag)std::cout<<"Should not happen double match in gen to tag finder for iso muon tag lepton"<<std::endl; matchTag =true; } } if(!matchTag) eventsFailingGenMatchForTagLeptonIsoMu_++; else eventsGenMatchForTagLeptonIsoMu_++; } for (unsigned int i=0; i<ProbeIsoMuonNum;i++) { if(!matchTag) break; if(truthMatching_ && GenMuNum!=2) break; // if(ProbeIsoMuonPt[0]<50) continue; ProbeActivity_=MuActivity(ProbeIsoMuonEta[i],ProbeIsoMuonPhi[i],muActivityMethod_); ProbePt_=ProbeIsoMuonPt[i]; ProbeEta_=ProbeIsoMuonEta[i]; ProbePhi_=ProbeIsoMuonPhi[i]; Probe_PassingOrFail_=ProbeIsoMuon_PassingOrFail[i]; if(Probe_PassingOrFail_==2)std::cout<<"This should not happen..."<<std::endl; Probe_InvariantMass_=ProbeIsoMuon_InvariantMass[i]; bool match=false; if(truthMatching_) { for(unsigned int ii=0; ii< GenMuNum; ii++) { if(deltaR(GenMuEta[ii],GenMuPhi[ii],ProbeEta_,ProbePhi_)<maxDeltaRGenToRecoMu_ && std::abs(GenMuPt[ii]-ProbePt_)/GenMuPt[ii] <maxDiffPtGenToRecoMu_) { if(match)std::cout<<"Error double match in isoMuon "<<std::endl; match =true; } } } if(truthMatching_ && !match) { // std::cout<<"Warning no match for probe muon(iso) found"<<std::endl; continue; } tTagAndProbeMuIso_->Fill(); } } return kTRUE; resetValues(); if(ProbeIDMuonNum>0 && MuID_minDeltaPhiN>minDeltaPhiN_) { if(TagIDMuonNum!=1) std::cout<<"Error this should never happen no tag id muon found but some probe!!!!!"<<std::endl; bool matchTag=false; if(truthMatching_) { for(unsigned int ii=0; ii< GenMuNum; ii++) { if(deltaR(GenMuEta[ii],GenMuPhi[ii],TagIDMuonEta[0],TagIDMuonPhi[0])<maxDeltaRGenToRecoMu_ && std::abs(GenMuPt[ii]-TagIDMuonPt[0])/GenMuPt[ii] <maxDiffPtGenToRecoMu_) { matchTag =true; } } if(!matchTag) eventsFailingGenMatchForTagLeptonRecoMu_++; else eventsGenMatchForTagLeptonRecoMu_++; } for (unsigned int i=0; i<ProbeIDMuonNum;i++) { if(matchTag) break; if(truthMatching_ && GenMuNum!=2) break; // if(ProbeIDMuonPt[0]<50) continue; ProbeActivity_=MuActivity(ProbeIDMuonEta[i],ProbeIDMuonPhi[i],muActivityMethod_); ProbePt_=ProbeIDMuonPt[i]; ProbeEta_=ProbeIDMuonEta[i]; ProbePhi_=ProbeIDMuonPhi[i]; Probe_PassingOrFail_=ProbeIDMuon_PassingOrFail[i]; Probe_InvariantMass_=ProbeIDMuon_InvariantMass[i]; bool match=false; if(truthMatching_) { for(unsigned int ii=0; ii< GenMuNum; ii++) { if(deltaR(GenMuEta[ii],GenMuPhi[ii],ProbeEta_,ProbePhi_)<maxDeltaRGenToRecoMu_ && std::abs(GenMuPt[ii]-ProbePt_)/GenMuPt[ii] <maxDiffPtGenToRecoMu_) { if(match)std::cout<<"Error double match in recoMuon "<<std::endl; match =true; } } } if(truthMatching_ && !match) continue; tTagAndProbeMuReco_->Fill(); } } resetValues(); if(ProbeIsoElectronNum>0 && ElecIso_minDeltaPhiN>minDeltaPhiN_) { if(TagIsoElectronNum!=1) std::cout<<"Error this should never happen no tag id electron found but some probe!!!!!"<<std::endl; bool matchTag=false; if(truthMatching_) { for(unsigned int ii=0; ii< GenElecNum; ii++) { if(deltaR(GenElecEta[ii],GenElecPhi[ii],TagIsoElectronEta[0],TagIsoElectronPhi[0])<maxDeltaRGenToRecoElec_ && std::abs(GenElecPt[ii]-TagIsoElectronPt[0])/GenElecPt[ii] <maxDiffPtGenToRecoElec_) { matchTag =true; } } if(!matchTag) eventsFailingGenMatchForTagLeptonIsoElec_++; else eventsGenMatchForTagLeptonIsoElec_++; } for (unsigned int i=0; i<ProbeIsoElectronNum;i++) { if(matchTag) break; if(truthMatching_ && GenElecNum!=2) break; // if(ProbeIsoElectronPt[0]<50) continue; ProbeActivity_=MuActivity(ProbeIsoElectronEta[i],ProbeIsoElectronPhi[i],elecActivityMethod_); ProbePt_=ProbeIsoElectronPt[i]; ProbeEta_=ProbeIsoElectronEta[i]; ProbePhi_=ProbeIsoElectronPhi[i]; Probe_PassingOrFail_=ProbeIsoElectron_PassingOrFail[i]; Probe_InvariantMass_=ProbeIsoElectron_InvariantMass[i]; bool match=false; if(truthMatching_) { for(unsigned int ii=0; ii< GenElecNum; ii++) { if(deltaR(GenElecEta[ii],GenElecPhi[ii],ProbeEta_,ProbePhi_)<maxDeltaRGenToRecoElec_ && std::abs(GenElecPt[ii]-ProbePt_)/GenElecPt[ii] <maxDiffPtGenToRecoElec_) { if(match)std::cout<<"Error double match in isoElec "<<std::endl; match =true; } } } if(truthMatching_ && !match) continue; tTagAndProbeElecIso_->Fill(); } } resetValues(); if(ProbeIDElectronNum>0 && ElecID_minDeltaPhiN>minDeltaPhiN_) { if(TagIDElectronNum!=1) std::cout<<"Error this should never happen no tag id electron found but some probe!!!!!"<<std::endl; bool matchTag=false; if(truthMatching_) { for(unsigned int ii=0; ii< GenElecNum; ii++) { if(deltaR(GenElecEta[ii],GenElecPhi[ii],TagIDElectronEta[0],TagIDElectronPhi[0])<maxDeltaRGenToRecoElec_ && std::abs(GenElecPt[ii]-TagIDElectronPt[0])/GenElecPt[ii] <maxDiffPtGenToRecoElec_) { matchTag =true; } } if(!matchTag) eventsFailingGenMatchForTagLeptonRecoElec_++; else eventsGenMatchForTagLeptonRecoElec_++; } for (unsigned int i=0; i<ProbeIDElectronNum;i++) { if(truthMatching_ && GenElecNum!=2) break; // if(ProbeIDElectronPt[0]<50) continue; ProbeActivity_=MuActivity(ProbeIDElectronEta[i],ProbeIDElectronPhi[i],elecActivityMethod_); ProbePt_=ProbeIDElectronPt[i]; ProbeEta_=ProbeIDElectronEta[i]; ProbePhi_=ProbeIDElectronPhi[i]; Probe_PassingOrFail_=ProbeIDElectron_PassingOrFail[i]; Probe_InvariantMass_=ProbeIDElectron_InvariantMass[i]; bool match=false; if(truthMatching_) { for(unsigned int ii=0; ii< GenElecNum; ii++) { if(deltaR(GenElecEta[ii],GenElecPhi[ii],ProbeEta_,ProbePhi_)<maxDeltaRGenToRecoElec_ && std::abs(GenElecPt[ii]-ProbePt_)/GenElecPt[ii] <maxDiffPtGenToRecoElec_) { if(match)std::cout<<"Error double match in recoElec "<<std::endl; match =true; } } } if(truthMatching_ && !match) continue; tTagAndProbeElecReco_->Fill(); } } return kTRUE; }
void readNtuplesNoFilter_forAN_isMC(TString inputfilename="results.root", int flavor=Sig::Prompt, std::string effmeasured="IterL3_NOHP_NOL1"){ bool doingL1 = effmeasured.find("L1OverOffline") != std::string::npos; TFile* outfile = TFile::Open(Form("%s_efficiency.root", effmeasured.c_str()),"RECREATE"); std::cout << "output file: " << outfile -> GetName() << std::endl; //Create histograms TH1F* dimuon_mass = new TH1F("h_dimuon_mass" ,"dimuon_mass" , 1500, 0, 150 ); TH1F* tagiso = new TH1F("h_tagiso" ,"tagiso" , 100, 0, 1 ); TH1F* tagMuonPt = new TH1F("h_tagMuonPt" ,"tagMuonPt" , 150, 0, 150 ); TH1F* nvtx_event = new TH1F("h_nvtx_event" ,"nvtx_event" , 60, 0, 60 ); // L1 over GEN: TEfficiency* L1muonPt = new TEfficiency("L1muonPt" ,"L1muonPt" , 16, pt_bins ); TEfficiency* L1muonEta = new TEfficiency("L1muonEta" ,"L1muonEta" , 15, eta_bins ); TEfficiency* L1muonPhi = new TEfficiency("L1muonPhi" ,"L1muonPhi" , 20, -3.2, 3.2); TEfficiency* L1muonEff = new TEfficiency("L1muonEff" ,"L1muonEff" , 1, 0., 1.0); // L2 over L1: TEfficiency* L2muonPt = new TEfficiency("L2muonPt" ,"L2muonPt" , 16, pt_bins ); TEfficiency* L2muonEta = new TEfficiency("L2muonEta" ,"L2muonEta" , 15, eta_bins ); TEfficiency* L2muonPhi = new TEfficiency("L2muonPhi" ,"L2muonPhi" , 20, -3.2, 3.2); TEfficiency* L2muonEff = new TEfficiency("L2muonEff" ,"L2muonEff" , 1, 0., 1.0); // L3 over L1: TEfficiency* muonPt = new TEfficiency("muonPt" ,"muonPt" , 16, pt_bins ); TEfficiency* muonPtTurnOn = new TEfficiency("muonPtTurnOn" ,"muonPtTurnOn" , 16, pt_bins ); TEfficiency* muonEta = new TEfficiency("muonEta" ,"muonEta" , 15, eta_bins ); TEfficiency* muonPhi = new TEfficiency("muonPhi" ,"muonPhi" , 20, -3.2, 3.2); TEfficiency* muonEff = new TEfficiency("muonEff" ,"muonEff" , 1, 0., 1.0); TEfficiency* muonDeltaR = new TEfficiency("muonDeltaR" ,"muonDeltaR" , 30, 0., 3.0); TEfficiency* muonDeltaPhi = new TEfficiency("muonDeltaPhi" ,"muonDeltaPhi" , 30, 0., 3.2); TEfficiency* failingMuonPt = new TEfficiency("failingMuonPt" ,"failingMuonPt" , 16, pt_bins ); TEfficiency* failingMuonEta = new TEfficiency("failingMuonEta" ,"failingMuonEta" , 15, eta_bins ); TEfficiency* failingMuonPhi = new TEfficiency("failingMuonPhi" ,"failingMuonPhi" , 20, -3.2, 3.2); TEfficiency* failingMuonEff = new TEfficiency("failingMuonEff" ,"failingMuonEff" , 1 , 0., 1.0); TEfficiency* fakeMuonPt = new TEfficiency("fakeMuonPt" ,"fakeMuonPt" , 16, pt_bins ); TEfficiency* fakeMuonEta = new TEfficiency("fakeMuonEta" ,"fakeMuonEta" , 15, eta_bins ); TEfficiency* fakeMuonPhi = new TEfficiency("fakeMuonPhi" ,"fakeMuonPhi" , 20, -3.2, 3.2); TEfficiency* fakeMuonEff = new TEfficiency("fakeMuonEff" ,"fakeMuonEff" , 1 , 0., 1.0); TH1F* PassingProbePt = new TH1F("h_PassingProbePt" ,"PassingMuonPt" , 16, pt_bins ); TH1F* PassingProbeEta = new TH1F("h_PassingProbeEta" ,"PassingMuonEta" , 15, eta_bins ); TH1F* PassingProbePhi = new TH1F("h_PassingProbePhi" ,"PassingMuonPhi" , 20, -3.2, 3.2); TH1F* PassingProbeMll = new TH1F("h_PassingProbeMll" ,"PassingMuonMll" , 40, 60., 120.); TH1F* PassingProbeDeltaR = new TH1F("h_PassingProbeDeltaR" ,"PassingMuonDeltaR", 30, 0., 3.0); TH1F* FailingProbePt = new TH1F("h_FailingProbePt" ,"FailingMuonPt" , 16, pt_bins ); TH1F* FailingProbeEta = new TH1F("h_FailingProbeEta" ,"FailingMuonEta" , 15, eta_bins ); TH1F* FailingProbePhi = new TH1F("h_FailingProbePhi" ,"FailingMuonPhi" , 20, -3.2, 3.2); TH1F* FailingProbeMll = new TH1F("h_FailingProbeMll" ,"FailingMuonMll" , 40, 60., 120.); TH1F* FailingProbeDeltaR = new TH1F("h_FailingProbeDeltaR" ,"FailingMuonDeltaR", 30, 0., 3.0); // Di-muon efficiencies TEfficiency* diMuonPt = new TEfficiency("diMuonPt" ,"diMuonPt" , 16, pt_bins , 16, pt_bins ); TEfficiency* diMuonEta = new TEfficiency("diMuonEta" ,"diMuonEta" , 15, eta_bins , 15, eta_bins ); TEfficiency* diMuonPhi = new TEfficiency("diMuonPhi" ,"diMuonPhi" , 20, -3.2, 3.2 , 20, -3.2, 3.2); TEfficiency* diMuonEff = new TEfficiency("diMuonEff" ,"diMuonEff" , 1, 0., 1.0); TEfficiency* diMuonDeltaR = new TEfficiency("diMuonDeltaR" ,"diMuonDeltaR" , 30, 0., 3.0); TEfficiency* diMuonLeadPt = new TEfficiency("diMuonLeadPt" ,"diMuonLeadPt" , 16, pt_bins ); TEfficiency* diMuonLeadEta = new TEfficiency("diMuonLeadEta" ,"diMuonLeadEta" , 15, eta_bins ); TEfficiency* diMuonLeadPhi = new TEfficiency("diMuonLeadPhi" ,"diMuonLeadPhi" , 20, -3.2, 3.2); TEfficiency* diMuonTrailPt = new TEfficiency("diMuonTrailPt" ,"diMuonTrailPt" , 16, pt_bins ); TEfficiency* diMuonTrailEta = new TEfficiency("diMuonTrailEta","diMuonTrailEta" , 15, eta_bins ); TEfficiency* diMuonTrailPhi = new TEfficiency("diMuonTrailPhi","diMuonTrailPhi" , 20, -3.2, 3.2); TEfficiency* nvtx = new TEfficiency("nvtx" ,"nvtx" , 60, 0, 60); TEfficiency* nvtx_barrel = new TEfficiency("nvtx_barrel" ,"nvtx_barrel" , 60, 0, 60); TEfficiency* nvtx_endcap = new TEfficiency("nvtx_endcap" ,"nvtx_endcap" , 60, 0, 60); TFile* inputfile = TFile::Open(inputfilename, "READ"); std::cout << "input file: " << inputfile -> GetName() << std::endl; TTree *tree = (TTree*) inputfile -> Get("muonNtuples/muonTree"); if (!tree) { std::cout << " *** tree not found *** " << std::endl; return; } MuonEvent* ev = new MuonEvent(); TBranch* evBranch = tree->GetBranch("event"); evBranch -> SetAddress(&ev); int nentries = tree->GetEntriesFast(); std::cout << "Number of entries = " << nentries << std::endl; bool flagfile = false; offlinePtCut = getLeadingPtCut(flavor); float ptcut1 = getLeadingPtCut(flavor); float ptcut2 = getTrailingPtCut(flavor); for (Int_t eventNo=0; eventNo < nentries; eventNo++) { Int_t IgetEvent = tree -> GetEvent(eventNo); if (!debug) printProgBar((int)(eventNo*100./nentries)); if (debug && eventNo==100) break; nvtx_event-> Fill( ev -> nVtx ); unsigned int nmuons = ev->genParticles.size(); for (int imu = 0; imu < nmuons; imu++){ if (! selectTagMuon(ev->genParticles.at(imu), tagiso)) continue; if (! matchMuon(ev->genParticles.at(imu), ev-> hltTag.objects, isofilterTag)) continue; tagMuonPt -> Fill ( ev->genParticles.at(imu).pt) ; for (int jmu = 0; jmu < nmuons; jmu++){ bool passL1 = false; bool passL2 = false; bool passL3 = false; // Select the probe muon & match to the probe: if (!selectProbeMuon(ev->genParticles.at(jmu), ev->genParticles.at(imu), dimuon_mass)) continue; // Check L1 passing: if (matchMuonWithL1(ev->genParticles.at(jmu),ev->L1muons)) passL1=true; // // // Check L2 passing: if (matchMuonWithHLT(ev->genParticles.at(jmu),ev->L2muons)) passL2=true; // // // Check L3 passing: if (matchMuonWithHLT(ev->genParticles.at(jmu),ev->hltmuons)) passL3=true; L1muonPt -> Fill( passL1 , ev->genParticles.at(jmu).pt ); L2muonPt -> Fill( passL2 && passL1, ev->genParticles.at(jmu).pt ); muonPtTurnOn -> Fill( passL3 && passL1, ev->genParticles.at(jmu).pt ); if (ev->genParticles.at(jmu).pt < ptcut1) continue; L1muonEta -> Fill( passL1, ev->genParticles.at(jmu).eta); L1muonPhi -> Fill( passL1, ev->genParticles.at(jmu).phi); L1muonEff -> Fill( passL1, 0.5 ); if (!passL1) continue; // exit the loop if there is no L1 // Fill L2: L2muonEta -> Fill( passL2, ev->genParticles.at(jmu).eta); L2muonPhi -> Fill( passL2, ev->genParticles.at(jmu).phi); L2muonEff -> Fill( passL2, 0.5 ); // Fill L3: TLorentzVector mu1, mu2; mu1.SetPtEtaPhiM (ev->genParticles.at(imu).pt,ev->genParticles.at(imu).eta,ev->genParticles.at(imu).phi, muonmass); mu2.SetPtEtaPhiM (ev->genParticles.at(jmu).pt,ev->genParticles.at(jmu).eta,ev->genParticles.at(jmu).phi, muonmass); double mumumass = (mu1 + mu2).M(); double DeltaR = mu1.DeltaR(mu2); double DeltaPhi = mu1.DeltaPhi(mu2); if (passL3) { PassingProbePt -> Fill( ev->genParticles.at(jmu).pt ); PassingProbeEta -> Fill( ev->genParticles.at(jmu).eta ); PassingProbePhi -> Fill( ev->genParticles.at(jmu).phi ); PassingProbeMll -> Fill( mumumass ); PassingProbeDeltaR-> Fill( DeltaR ); } else { FailingProbePt -> Fill( ev->genParticles.at(jmu).pt ); FailingProbeEta -> Fill( ev->genParticles.at(jmu).eta ); FailingProbePhi -> Fill( ev->genParticles.at(jmu).phi ); FailingProbeMll -> Fill( mumumass ); FailingProbeDeltaR-> Fill( DeltaR ); } muonPt -> Fill( passL3, ev->genParticles.at(jmu).pt ); muonEta -> Fill( passL3, ev->genParticles.at(jmu).eta); muonPhi -> Fill( passL3, ev->genParticles.at(jmu).phi); muonEff -> Fill( passL3, 0.5 ); muonDeltaR -> Fill( passL3, DeltaR); muonDeltaPhi -> Fill( passL3, DeltaPhi); failingMuonPt -> Fill( !passL3, ev->genParticles.at(jmu).pt ); failingMuonEta -> Fill( !passL3, ev->genParticles.at(jmu).eta); failingMuonPhi -> Fill( !passL3, ev->genParticles.at(jmu).phi); failingMuonEff -> Fill( !passL3, 0.5 ); } // nmuons } /// Now FOR DIMUONS (Using HLT info): // both should pass the L1 filter! continue; if (debug) cout << "fired L1?" << endl; if (ev->L1muons.size()>1) { if (debug) cout << "YES!" << endl; for (int imu=0; imu<ev->hltmuons.size(); imu++){ bool fake = false; if (!matchHLTMuonWithGen(ev->hltmuons.at(imu), ev->genParticles)) fake = true; fakeMuonPt -> Fill( fake, ev->hltmuons.at(imu).pt ); if (ev->hltmuons.at(imu).pt > ptcut1) { fakeMuonEta -> Fill( fake, ev->hltmuons.at(imu).eta); fakeMuonPhi -> Fill( fake, ev->hltmuons.at(imu).phi); fakeMuonEff -> Fill( fake, 0.5 ); } for (int jmu=imu+1; jmu<ev->hltmuons.size(); jmu++){ bool pass = false; if (matchHLTMuonWithGen(ev->hltmuons.at(imu),ev->genParticles) && matchHLTMuonWithGen(ev->hltmuons.at(jmu),ev->genParticles)) pass = true; double DeltaR = deltaR(ev->hltmuons.at(imu).eta,ev->hltmuons.at(imu).phi,ev->hltmuons.at(jmu).eta,ev->hltmuons.at(jmu).phi); diMuonPt -> Fill( pass, ev->hltmuons.at(imu).pt , ev->hltmuons.at(jmu).pt ); diMuonLeadPt -> Fill( pass, ev->hltmuons.at(imu).pt ); diMuonTrailPt -> Fill( pass, ev->hltmuons.at(jmu).pt ); if (ev->hltmuons.at(imu).pt < ptcut1) continue; if (ev->hltmuons.at(jmu).pt < ptcut2) continue; diMuonEta -> Fill( pass, ev->hltmuons.at(imu).eta, ev->hltmuons.at(jmu).eta ); diMuonPhi -> Fill( pass, ev->hltmuons.at(imu).phi, ev->hltmuons.at(jmu).phi ); diMuonDeltaR -> Fill( pass, DeltaR); diMuonEff -> Fill( pass, 0.5); diMuonLeadEta -> Fill( pass, ev->hltmuons.at(imu).eta ); diMuonTrailEta -> Fill( pass, ev->hltmuons.at(jmu).eta ); diMuonLeadPhi -> Fill( pass, ev->hltmuons.at(imu).phi ); diMuonTrailPhi -> Fill( pass, ev->hltmuons.at(jmu).phi ); } } /* for (int imu = 0; imu < nmuons; imu++){ if (!selectMuon(ev->genParticles.at(imu))) continue; for (int jmu = imu+1; jmu < nmuons; jmu++){ if (!selectMuon(ev->genParticles.at(jmu))) continue; bool pass = false; if (matchMuonWithL3(ev->genParticles.at(jmu),ev->hltmuons) && matchMuonWithL3(ev->genParticles.at(imu),ev->hltmuons)) pass = true; if (ev->genParticles.at(imu).pt == ev->genParticles.at(jmu).pt) continue; if (ev->genParticles.at(imu).eta == ev->genParticles.at(jmu).eta) continue; if (ev->genParticles.at(imu).phi == ev->genParticles.at(jmu).phi) continue; double DeltaR = deltaR(ev->genParticles.at(imu).eta,ev->genParticles.at(imu).phi,ev->genParticles.at(jmu).eta,ev->genParticles.at(jmu).phi); h_diMuonDeltaR -> Fill( DeltaR ); diMuonPt -> Fill( pass, ev->genParticles.at(imu).pt ); diMuonEta -> Fill( pass, ev->genParticles.at(imu).eta); diMuonPhi -> Fill( pass, ev->genParticles.at(imu).phi); diMuonPt -> Fill( pass, ev->genParticles.at(jmu).pt ); diMuonEta -> Fill( pass, ev->genParticles.at(jmu).eta); diMuonPhi -> Fill( pass, ev->genParticles.at(jmu).phi); diMuonDeltaR -> Fill( pass, DeltaR); diMuonDeltaR -> Fill( pass, DeltaR); diMuonEff -> Fill( pass, 0.5); diMuonEff -> Fill( pass, 0.5); } } */ } } //Writing the histograms in a file. outfile -> cd(); tagMuonPt -> Write(); L1muonPt -> Write(); L1muonEta -> Write(); L1muonPhi -> Write(); L1muonEff -> Write(); L2muonPt -> Write(); L2muonEta -> Write(); L2muonPhi -> Write(); L2muonEff -> Write(); muonPtTurnOn -> Write(); muonPt -> Write(); muonEta -> Write(); muonPhi -> Write(); muonEff -> Write(); muonDeltaR -> Write(); muonDeltaPhi -> Write(); failingMuonPt -> Write(); failingMuonEta -> Write(); failingMuonPhi -> Write(); failingMuonEff -> Write(); fakeMuonPt -> Write(); fakeMuonEta -> Write(); fakeMuonPhi -> Write(); fakeMuonEff -> Write(); PassingProbePt -> Write(); PassingProbeEta -> Write(); PassingProbePhi -> Write(); PassingProbeMll -> Write(); PassingProbeDeltaR -> Write(); FailingProbePt -> Write(); FailingProbeEta -> Write(); FailingProbePhi -> Write(); FailingProbeMll -> Write(); FailingProbeDeltaR -> Write(); /// Per-event (di-muon) efficiency. diMuonPt -> Write(); diMuonEta -> Write(); diMuonPhi -> Write(); diMuonEff -> Write(); diMuonDeltaR -> Write(); diMuonLeadPt -> Write(); diMuonLeadEta -> Write(); diMuonLeadPhi -> Write(); diMuonTrailPt -> Write(); diMuonTrailEta -> Write(); diMuonTrailPhi -> Write(); nvtx_event -> Write(); nvtx -> Write(); dimuon_mass -> Write(); tagiso -> Write(); outfile -> Close(); return; }
void HiForest::correlateTracks(TTree* jetTree, Jets& jets, bool allEvents, bool smeared){ vector<TBranch*> branches(0); if(allEvents || currentEvent == 0){ if(1){ jtChg = new Float_t[maxEntry]; jtNeut = new Float_t[maxEntry]; jtEM = new Float_t[maxEntry]; jtChgGen = new Float_t[maxEntry]; jtNeutGen = new Float_t[maxEntry]; jtEMGen = new Float_t[maxEntry]; jtPtMax = new Float_t[maxEntry]; jtPtMean = new Float_t[maxEntry]; jtPtMeanW = new Float_t[maxEntry]; jtLeadType = new Int_t[maxEntry]; } tjDeltaEtaLead = new Float_t[maxEntryTrack]; tjDeltaPhiLead = new Float_t[maxEntryTrack]; zLead = new Float_t[maxEntryTrack]; tjDeltaEtaSubLead = new Float_t[maxEntryTrack]; tjDeltaPhiSubLead = new Float_t[maxEntryTrack]; zSubLead = new Float_t[maxEntryTrack]; zOldLead = new Float_t[maxEntryTrack]; zOldSubLead = new Float_t[maxEntryTrack]; zSingleLead = new Float_t[maxEntryTrack]; zLabLead = new Float_t[maxEntryTrack]; tjDeltaThetaLead = new Float_t[maxEntryTrack]; tjDeltaThetaLabLead = new Float_t[maxEntryTrack]; tjDeltaThetaSingleLead = new Float_t[maxEntryTrack]; zSingleSubLead = new Float_t[maxEntryTrack]; zLabSubLead = new Float_t[maxEntryTrack]; tjDeltaThetaSubLead = new Float_t[maxEntryTrack]; tjDeltaThetaLabSubLead = new Float_t[maxEntryTrack]; tjDeltaThetaSingleSubLead = new Float_t[maxEntryTrack]; corrLead = new Float_t[maxEntryTrack]; corrSubLead = new Float_t[maxEntryTrack]; branches.push_back(jetTree->Branch("jtChg",jtChg,"jtChg[nref]/F")); branches.push_back(jetTree->Branch("jtNeut",jtNeut,"jtNeut[nref]/F")); branches.push_back(jetTree->Branch("jtEM",jtEM,"jtEM[nref]/F")); branches.push_back(jetTree->Branch("jtChgGen",jtChgGen,"jtChgGen[nref]/F")); branches.push_back(jetTree->Branch("jtNeutGen",jtNeutGen,"jtNeutGen[nref]/F")); branches.push_back(jetTree->Branch("jtEMGen",jtEMGen,"jtEMGen[nref]/F")); branches.push_back(jetTree->Branch("jtPtMax",jtPtMax,"jtPtMax[nref]/F")); branches.push_back(jetTree->Branch("jtPtMean",jtPtMean,"jtPtMean[nref]/F")); branches.push_back(jetTree->Branch("jtPtMeanW",jtPtMeanW,"jtPtMeanW[nref]/F")); branches.push_back(jetTree->Branch("jtLeadType",jtLeadType,"jtLeadType[nref]/I")); branches.push_back(trackTree->Branch("tjDetaLead",tjDeltaEtaLead,"tjDetaLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDphiLead",tjDeltaPhiLead,"tjDphiLead[nTrk]/F")); branches.push_back(trackTree->Branch("zLead",zLead,"zLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDetaSubLead",tjDeltaEtaSubLead,"tjDetaSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDphiSubLead",tjDeltaPhiSubLead,"tjDphiSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("zSubLead",zSubLead,"zSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("zOldLead",zOldLead,"zOldLead[nTrk]/F")); branches.push_back(trackTree->Branch("zOldSubLead",zOldSubLead,"zOldSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("zSingleLead",zSingleLead,"zSingleLead[nTrk]/F")); branches.push_back(trackTree->Branch("zSingleSubLead",zSingleSubLead,"zSingleSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("zLabLead",zLabLead,"zLabLead[nTrk]/F")); branches.push_back(trackTree->Branch("zLabSubLead",zSubLead,"zLabSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDthetaLead",tjDeltaThetaLead,"tjDthetaLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDthetaLabLead",tjDeltaThetaLabLead,"tjDthetaLabLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDthetaSingleLead",tjDeltaThetaSingleLead,"tjDthetaSingleLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDthetaSubLead",tjDeltaThetaSubLead,"tjDthetaSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDthetaLabSubLead",tjDeltaThetaLabSubLead,"tjDthetaLabSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDthetaSingleSubLead",tjDeltaThetaSingleSubLead,"tjDthetaSingleSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("corrLead",corrLead,"corrLead[nTrk]/F")); branches.push_back(trackTree->Branch("corrSubLead",corrSubLead,"corrSubLead[nTrk]/F")); jetTree->SetAlias("jtFracChg","jtChg/jtpt"); jetTree->SetAlias("jtFracNeut","jtNeut/jtpt"); jetTree->SetAlias("jtFracEM","jtFracEM/jtpt"); jetTree->SetAlias("refFracChg","jtChg/refpt"); jetTree->SetAlias("refFracNeut","jtNeut/refpt"); jetTree->SetAlias("refFracEM","jtFracEM/refpt"); jetTree->SetAlias("jtFracChgGen","jtChgGen/jtpt"); jetTree->SetAlias("jtFracNeutGen","jtNeutGen/refpt"); jetTree->SetAlias("jtFracEMGen","jtFracEMGen/refpt"); trackTree->SetAlias("tjDRlead","sqrt(tjDetaLead*tjDetaLead+tjDphiLead*tjDphiLead)"); trackTree->SetAlias("tjDRsublead","sqrt(tjDetaSubLead*tjDetaSubLead+tjDphiSubLead*tjDphiSubLead)"); } double correctionFactors[4] = {0,0,0,0}; for (int i=0; allEvents ? i<GetEntries() : 1;i++){ if(i % 1000 == 0) cout<<"Processing Event : "<<i<<endl; if(allEvents){ jetTree->GetEntry(i); trackTree->GetEntry(i); hltTree->GetEntry(i); } int cbin = evt.hiBin; if(collisionMode == cPP) cbin = 33; double eventEta = 0; if(hasDiJet(jets)) eventEta = (jets.jteta[jtLead]+jets.jteta[jtSubLead])/2.; for(int j = 0; j < jets.nref; ++j){ jtChg[j] = 0; jtNeut[j] = 0; jtEM[j] = 0; jtPtMax[j] = 0; jtPtMean[j] = 0; jtPtMeanW[j] = 0; jtLeadType[j] = 0; for (int t = 0; t < track.nTrk; ++t) { double jetPt = jets.jtpt[j]; if(smeared)jetPt = jets.smpt[j]; if(j == jtLead){ tjDeltaEtaLead[t] = track.trkEta[t] - jets.jteta[j]; tjDeltaPhiLead[t] = deltaPhi(track.trkPhi[t],jets.jtphi[j]); zOldLead[t] = track.trkPt[t]/jetPt; zLead[t] = getProjectedZ(jetPt,jets.jteta[j],jets.jtphi[j],track.trkPt[t],track.trkEta[t],track.trkPhi[t],eventEta); // cout<<"jtpt : "<<jets.jtpt[j]<<" spt : "<<jets.smpt[j]<<endl; corrLead[t] = trackCorrections[0]->GetCorr(track.trkPt[t],track.trkEta[t],jetPt,cbin,correctionFactors); } if(j == jtSubLead){ tjDeltaEtaSubLead[t] = track.trkEta[t] - jets.jteta[j]; tjDeltaPhiSubLead[t] = deltaPhi(track.trkPhi[t],jets.jtphi[j]); zSubLead[t] = getProjectedZ(jetPt,jets.jteta[j],jets.jtphi[j],track.trkPt[t],track.trkEta[t],track.trkPhi[t],eventEta); zOldSubLead[t] = track.trkPt[t]/jetPt; corrSubLead[t] = trackCorrections[1]->GetCorr(track.trkPt[t],track.trkEta[t],jetPt,cbin,correctionFactors); } double dr = deltaR(track.trkEta[t],track.trkPhi[t],jets.jteta[j],jets.jtphi[j]); if(dr > cone) continue; if(jtPtMax[j] < track.trkPt[t]) jtPtMax[j] = track.trkPt[t]; jtChg[j] += track.trkPt[t]; } } for(unsigned int ib = 0; ib < branches.size(); ++ib){ branches[ib]->Fill(); } } return; }
void nmssm_wh_4b::Loop() { // In a ROOT session, you can do: // Root > .L nmssm_wh_4b.C // Root > nmssm_wh_4b t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; TH1F * hptl = new TH1F( "hptl", "ptl", 20, 0., 100.); TH1F * hetal = new TH1F( "hetal", "etal", 50, -5.0, 5.0); TH1F * hptb = new TH1F( "hptb", "ptb", 20, 0., 100.); TH1F * hetab = new TH1F( "hetab", "etab", 50, -5.0, 5.0); TH1F * hdrlbmin = new TH1F( "hdrlbmin", "drlbmin", 25, 0., 5.0); TH1F * hdrb1b2 = new TH1F( "hdrb1b2", "drb1b2", 25, 0., 5.0); TH1F * hdrb1b3 = new TH1F( "hdrb1b3", "drb1b3", 25, 0., 5.0); TH1F * hdrb1b4 = new TH1F( "hdrb1b4", "drb1b4", 25, 0., 5.0); TH1F * hdrb2b3 = new TH1F( "hdrb2b3", "drb2b3", 25, 0., 5.0); TH1F * hdrb2b4 = new TH1F( "hdrb2b4", "drb2b4", 25, 0., 5.0); TH1F * hdrb3b4 = new TH1F( "hdrb3b4", "drb3b4", 25, 0., 5.0); // TH2F * hdsbj = new TH2F( "hhdsbj", "hdsbj", 7, 0., 7., 7, 0., 7.); TH1F * hdsbj = new TH1F( "hdsbj", "hdsbj", 8, 0., 8.); int ntot = 0; int lpteta = 0; int bpteta = 0; int drlb = 0; double nbtot = 0.; double nbhe = 0.; double di_b_jet = 0.; double single_b_jet = 0.; vector<int> twobjet1stindex; vector<int> twobjet2ndindex; vector<int> singlebindex; vector<double> drpair; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; ntot += 1; // select pt/eta lepton if(ptl < 20. || fabs(etal) > 2.4) {continue;} lpteta += 1; hptl->Fill(ptl); hetal->Fill(etal); Double_t drb1b2 = deltaR((*etab)[0],(*phib)[0],(*etab)[1],(*phib)[1]); Double_t drb1b3 = deltaR((*etab)[0],(*phib)[0],(*etab)[2],(*phib)[2]); Double_t drb1b4 = deltaR((*etab)[0],(*phib)[0],(*etab)[3],(*phib)[3]); Double_t drb2b3 = deltaR((*etab)[1],(*phib)[1],(*etab)[2],(*phib)[2]); Double_t drb2b4 = deltaR((*etab)[1],(*phib)[1],(*etab)[3],(*phib)[3]); Double_t drb3b4 = deltaR((*etab)[2],(*phib)[2],(*etab)[3],(*phib)[3]); hdrb1b2->Fill(drb1b2); hdrb1b3->Fill(drb1b3); hdrb1b4->Fill(drb1b4); hdrb2b3->Fill(drb2b3); hdrb2b4->Fill(drb2b4); hdrb3b4->Fill(drb3b4); twobjet1stindex.clear(); twobjet2ndindex.clear(); singlebindex.clear(); Int_t ndbj = 0; Int_t nbj = ptb->size(); for (unsigned int i = 0; i < nbj-1; i++) { for (unsigned int j = i+1; j < nbj; j++) { Double_t dr = deltaR((*etab)[i],(*phib)[i],(*etab)[j],(*phib)[j]); if(dr < 0.5) { twobjet1stindex.push_back(i); twobjet2ndindex.push_back(j); drpair.push_back(dr); // cout <<" dr = " << dr // <<" i = " << i // <<" j = " << j << endl; } } } Int_t ndbj = twobjet1stindex.size(); for (unsigned int i = 0; i < nbj; i++) { Int_t sj = 1; for (unsigned int i2 = 0; i2 < ndbj; i2++) { if(i == twobjet1stindex[i2] || i == twobjet2ndindex[i2]) {sj = 0;} } if(sj == 1) {singlebindex.push_back(i);} } Int_t nsbj = singlebindex.size(); if(nsbj == 4 ) { cout <<" " << endl; cout <<" ==> Next event nsbj = " << nsbj <<" ndbj = " << ndbj << endl; for (unsigned int i = 0; i < nsbj; i++) { cout <<" singlebindex j = " << singlebindex[i] << endl; } for (unsigned int i = 0; i < ndbj; i++) { cout <<" pair ij =" << twobjet1stindex[i] <<" " << twobjet2ndindex[i] <<" dr = " << drpair[i] << endl; } } hdsbj->Fill(1.*nsbj); // select pt/eta b int b_in_acc = 1; for (unsigned int j = 0; j < nbj; j++) { if( (*ptb)[j] < 0. || fabs((*etab)[j]) > 4.0) {b_in_acc = 0;} } if(b_in_acc == 0) {continue;} bpteta += 1; for (unsigned int j = 0; j < nbj; j++) { hptb->Fill((*ptb)[j]); if((*ptb)[j] > 30.) hetab->Fill((*etab)[j]); } // DR l-b > 0.5 Double_t drlb_min = 1000.; for (unsigned int j = 0; j < nbj; j++) { Double_t dr = deltaR((*etab)[j],(*phib)[j],etal,phil); if(dr < drlb_min) { drlb_min = dr; } } if(drlb_min < 0.5) {continue;} drlb += 1; hdrlbmin->Fill(drlb_min); // if (Cut(ientry) < 0) continue; } cout <<" ========= Selections =========== " << endl; cout <<" nton = " << ntot << endl; cout <<" lpteta = " << lpteta << endl; cout <<" bpteta = " << bpteta << endl; cout <<" drlb = " << drlb << endl; //TFile efile("nmssm_wh_4b_mh60_histos.root","recreate"); TFile efile("nmssm_wh_4b_mh60_histos.root","recreate"); hptl->Write(); hetal->Write(); hptb->Write(); hetab->Write(); hdrlbmin->Write(); hdrb1b2->Write(); hdrb1b3->Write(); hdrb1b4->Write(); hdrb2b3->Write(); hdrb2b4->Write(); hdrb3b4->Write(); hdsbj->Write(); efile.Close(); }