double BTagWeight::getUDSGScaleFactor(const Jet& jet) const { double pt = getSmearedJetPtScale(jet, 0)*jet.pt(); double eta = jet.eta(); double SF_udsg_mean(0), SF_udsg_min(0), SF_udsg_max(0); if (pt < 20) { return 0; } else if (pt > 800) { SF_udsg_mean = getMeanUDSGScaleFactor(800., eta); SF_udsg_min = getMinUDSGScaleFactor(800, eta); SF_udsg_max = getMaxUDSGScaleFactor(800, eta); //use twice the uncertainty SF_udsg_min -= (SF_udsg_mean - SF_udsg_min); SF_udsg_max += (SF_udsg_max - SF_udsg_mean); } else { SF_udsg_mean = getMeanUDSGScaleFactor(pt, eta); SF_udsg_min = getMinUDSGScaleFactor(pt, eta); SF_udsg_max = getMaxUDSGScaleFactor(pt, eta); } if (LightJetSystematic_ == -1) return SF_udsg_min; else if (LightJetSystematic_ == 1) return SF_udsg_max; return SF_udsg_mean; }
void LHCOWriter::AnalyseJets() { Jet *element; Track *track; Int_t counter; fItJet->Reset(); while((element = static_cast<Jet*>(fItJet->Next()))) { if(element->TauTag != 0) continue; Reset(); counter = 0; fItTrack->Reset(); while((track = static_cast<Track*>(fItTrack->Next()))) { if(element->P4().DeltaR(track->P4()) < 0.5) ++counter; } fIntParam[1] = 4; fDblParam[0] = element->Eta; fDblParam[1] = element->Phi; fDblParam[2] = element->PT; fDblParam[3] = element->Mass; fDblParam[4] = counter; fDblParam[5] = element->BTag; fDblParam[6] = element->EhadOverEem; Write(); } }
void timer(int v) { moveBullets(); jet.calcDir(); jet.moveJet(); placeCamera(); glutPostRedisplay(); // Vector3d axis = jet.up.cross(jet.forward); // debugLog(jet.forward, jet.up, axis); glutTimerFunc(50, timer, v); }
Jet MuXboostedBTagging::Result(std::vector<Lepton> const &muons, Jet const &jet, Jet &core) const { INFO0; // Keep track of the smallest x for any muon auto min_x = std::numeric_limits<double>::max(); // Large enough, simple significand // Iterate through each muon, add it to the core, and calculate the resulting boost invariant auto p4_neutrino_correction = Jet {}; for (auto const &muon : muons) { // Add back the muon and the neutrino core += 2 * muon; // Set a hard ceiling on subjet mass, for poor reconstruction auto dot = muon.Spatial().Dot(core.Spatial()); auto min = std::min(core.Mass(), MaxSubJetMass()); if (dot == 0_eV * eV || min == 0_eV) continue; auto cross = muon.Spatial().Cross(core.Spatial()).Mag(); auto x_core = static_cast<double>(core.Energy() * cross / dot / min); CHECK(x_core >= 0, x_core); if (x_core < 0) return jet; // Add the neutrino to original jet IFF the muon passes the boosted test if (x_core <= XMax()) p4_neutrino_correction += muon; min_x = std::min(min_x, x_core); } auto result = jet + p4_neutrino_correction; CHECK(result.Pt() > 0_eV, result.Pt()); CHECK(!(result.Pt() != result.Pt()), result.Pt()) CHECK(!(core.Pt() != core.Pt()), core.Pt()) CHECK(!(min_x != min_x), min_x) if (result.Pt() <= 0_eV) return jet; result.SetInfo(jet.Info()); result.Info().SetMuBTag(min_x, core.Pt() / result.Pt()); return result; }
double BTagWeight::getUDSGScaleFactor(const Jet& jet, std::string MCSampleTag) const { double pt = getSmearedJetPtScale(jet, 0)*jet.pt(); double eta = jet.eta(); double SF_udsg_mean(0), SF_udsg_min(0), SF_udsg_max(0); if (MCSampleTag == "Summer12") { // 2012 if (pt < 20) { return 0; } else if (pt > 850 && eta >= 1.6 && eta <= 2.4) { SF_udsg_mean = getMeanUDSGScaleFactor(850., eta, MCSampleTag); SF_udsg_min = getMinUDSGScaleFactor(850, eta, MCSampleTag); SF_udsg_max = getMaxUDSGScaleFactor(850, eta, MCSampleTag); //use twice the uncertainty SF_udsg_min -= (SF_udsg_mean - SF_udsg_min); SF_udsg_max += (SF_udsg_max - SF_udsg_mean); } else if (pt > 1000) { SF_udsg_mean = getMeanUDSGScaleFactor(1000., eta, MCSampleTag); SF_udsg_min = getMinUDSGScaleFactor(1000, eta, MCSampleTag); SF_udsg_max = getMaxUDSGScaleFactor(1000, eta, MCSampleTag); //use twice the uncertainty SF_udsg_min -= (SF_udsg_mean - SF_udsg_min); SF_udsg_max += (SF_udsg_max - SF_udsg_mean); } else { SF_udsg_mean = getMeanUDSGScaleFactor(pt, eta, MCSampleTag); SF_udsg_min = getMinUDSGScaleFactor(pt, eta, MCSampleTag); SF_udsg_max = getMaxUDSGScaleFactor(pt, eta, MCSampleTag); } } else if (MCSampleTag == "Summer11Leg") { // 2011 if (pt < 20) { return 0; } else if (pt > 670 && eta >= 0. && eta <= 2.4) { // Use integrated over all eta SF_udsg_mean = getMeanUDSGScaleFactor(pt, eta, MCSampleTag); SF_udsg_min = getMinUDSGScaleFactor(pt, eta, MCSampleTag); SF_udsg_max = getMaxUDSGScaleFactor(pt, eta, MCSampleTag); //use twice the uncertainty SF_udsg_min -= (SF_udsg_mean - SF_udsg_min); SF_udsg_max += (SF_udsg_max - SF_udsg_mean); } else { SF_udsg_mean = getMeanUDSGScaleFactor(pt, eta, MCSampleTag); SF_udsg_min = getMinUDSGScaleFactor(pt, eta, MCSampleTag); SF_udsg_max = getMaxUDSGScaleFactor(pt, eta, MCSampleTag); } } if (LightJetSystematic_ == -1) { return SF_udsg_min; } else if (LightJetSystematic_ == 1) { return SF_udsg_max; } return SF_udsg_mean; }
int main() { // Wyrażenie sin( (x + 2) * x). Rozwijam w x0 = 3.5; liczę wartość w 4.0 Jet<double> x ( 5); x.set(0, 3.5); x.set(1, 1.0); Jet<double> c2 ( 5); c2.set(0, 2.0); cout<<"wynik: "<<getTaylor(sin( (x+c2) * x) , x.get(0), 4.0)<<endl; cout<<"wynik oczekiwany: "<< sin( (4.0 + 2) * 4.0) <<endl; // Wyrażenie pow( 2.0/x + 2, 2.72). Rozwijam w x0 = 3.5; liczę wartość w 4.0 cout<<"wynik: "<<getTaylor(pow( c2/x + c2, 2.72) , x.get(0), 4.0)<<endl; cout<<"wynik oczekiwany: "<< pow( 2.0/4.0 + 2.0, 2.72) <<endl; // Wyrażenie log( x/(x+2) +2 + sin(cos(x))) . Rozwijam w x0 = 3.5; liczę wartość w 4.0 cout<<"wynik: "<<getTaylor(log(x/(x+c2) +c2 + sin(cos(x))) , x.get(0), 4.0)<<endl; cout<<"wynik oczekiwany: "<< log(4.0/(4.0+2.0) +2.0 + sin(cos(4.0))) <<endl; // Wyrażenie sin(y) całuję od 0 do 2 PI. Jet<double> y ( 21); y.set(0, 0.0); y.set(1, 1.0); cout<<"wynik: "<< integrate(sin(y),y.get(0), 0.0, 2.0 * M_PI, 200, 34)<<endl; cout<<"oczekiwnany: 0"<<endl; return 0; }
void fillPFCandVsCount ( Jet & jet, TH2F* hist ){ const int n_ids = 8; int pfcand_ids[n_ids + 1]; memset ( pfcand_ids, 0, sizeof (pfcand_ids)); int nPFCands = jet.getNPFCandidates(); for (int iPFCand = 0; iPFCand < nPFCands; ++iPFCand){ PFCand cand = jet.getPFCandidate( iPFCand ); pfcand_ids[cand.Id()]++; pfcand_ids[n_ids]++; } for (int i = 0; i <= n_ids; ++i) hist -> Fill(i, pfcand_ids[i]); }
std::vector<Jet> MuXboostedBTagging::CoreCandidates(std::vector<Lepton> const &muons, Jet const &jet) const { INFO0; auto recluster_input = muons; for (auto const &consituent : jet.Constituents()) { if (consituent.Info().ContainsDetectorPart(DetectorPart::tower) && consituent.Pt() < min_tower_pt_ratio_ * jet.Pt()) continue; // Don't use recluster_input.emplace_back(consituent); } // Recluster the jet, to find core candidates auto cluster_sequence = boca::ClusterSequence {recluster_input, fastjet::JetDefinition(fastjet::antikt_algorithm, core_jet_radius / rad, &Settings::Recombiner())}; // Get the core candidates (NOT sorted by pT until we remove muons) auto core_candidates = cluster_sequence.InclusiveJets(); if (core_candidates.empty()) return core_candidates; cluster_sequence.NoLongerNeeded(); // If a taggable muon is inside a core candidate, remove the muon p4 for (auto const &muon : muons) for (auto &core_candidate : core_candidates) if (muon.DeltaRTo(core_candidate) < core_jet_radius) { core_candidate -= muon; break; } // Sort the core candidates by pT (highest to lowest) core_candidates = SortedByPt(core_candidates); return core_candidates; }
Type getTaylor(const Jet<Type> &jet, const Type &x0, const Type &x, int n = -1) { Type out = 0; Type powerAcc = 1; if(n == -1) n = jet.length(); for(int i = 0; i < n; i++) { out += jet.get(i) * powerAcc; powerAcc *= (x - x0); } return out; }
void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glColor3ub(0,0,0); glPushMatrix(); glScaled(100, .05, .05); DrawCube(0, 0, 0, 4, true); glPopMatrix(); glPushMatrix(); glScaled(.05, 100, .05); DrawCube(0, 0, 0, 4, true); glPopMatrix(); glPushMatrix(); glScaled(.05, .05, 100); DrawCube(0, 0, 0, 4, true); glPopMatrix(); paintGridAround(400); //DrawCube(0, 0, 0, 4, true); paintBullets(); jet.paintJet(); glutSwapBuffers(); }
bool Analysis::DphiCuts(){ bool IsCutPass = false; if (branchJet && branchMissingET){ MissingET *met = (MissingET*) branchMissingET->At(0); int nJets = branchJet->GetEntriesFast(); for (int i=0; i < nJets; i++){ Jet *jet = (Jet*) branchJet->At(i); if (jet->PT > 200.){ if (jet->P4().DeltaR(met->P4()) > 1.) IsCutPass=true; else {IsCutPass=false; break;} } } } IsEventPass = IsEventPass && IsCutPass; return IsCutPass; }
void keyboard(unsigned char key, int, int) { // float radv = (jet.ver + 15) * 3.1416 / 180; Vector3d axis; axis = jet.up.cross(jet.forward); float angle = PI/16; switch(key) { case 'w': rotateAxisVec(angle, axis, jet.forward); rotateAxisVec(angle, axis, jet.up); break; case 's': rotateAxisVec(-angle, axis, jet.forward); rotateAxisVec(-angle, axis, jet.up); break; case 'a': rotateUpZ(-angle, jet.forward, jet.up); break; case 'd': rotateUpZ(angle, jet.forward, jet.up); break; // case 'w': // jet.ver = (int)( jet.ver - 10) % 360; // break; // case 'a': // jet.hor = (int)( jet.hor + ((int) 10 * cos(radv)/abs(cos(radv)))) % 360; // break; // case 's': // jet.ver = (int)( jet.ver + 10) % 360; // break; // case 'd': // jet.hor = (int)( jet.hor - (10 * cos(radv)/abs(cos(radv)))) % 360; // break; case 'q': jet.jetBoost(); break; case 'e': jet.jetBrake(); break; } jet.up.normalize(); jet.forward.normalize(); axis = jet.up.cross(jet.forward); // debugLog(jet.forward, jet.up, axis); }
Jet* JetTruthEval::get_truth_jet(PHG4Particle* particle) { if (_strict) {assert(particle);} else if (!particle) {++_errors; return NULL;} if (_do_cache) { std::map<PHG4Particle*,Jet*>::iterator iter = _cache_get_truth_jet.find(particle); if (iter != _cache_get_truth_jet.end()) { return iter->second; } } Jet* truth_jet = NULL; // loop over all jets and look for this particle... for (JetMap::Iter iter = _truthjets->begin(); iter != _truthjets->end(); ++iter) { Jet* candidate = iter->second; // loop over all consituents and look for this particle for (Jet::ConstIter jter = candidate->begin_comp(); jter != candidate->end_comp(); ++jter) { unsigned int index = jter->second; PHG4Particle* constituent = _truthinfo->GetParticle( index ); if (_strict) {assert(constituent);} else if (!constituent) {++_errors; continue;} if (get_svtx_eval_stack()->get_truth_eval()->are_same_particle(constituent,particle)) { truth_jet = candidate; break; } } if (truth_jet) break; } if (_do_cache) _cache_get_truth_jet.insert(make_pair(particle,truth_jet)); return truth_jet; }
double JetInfo::CoreEnergyFraction(Jet const &jet) const { DEBUG0; auto energy = 0_eV; auto core_energy = 0_eV; for (auto const &constituent : Constituents()) if (constituent.DetectorPart() == DetectorPart::photon) { energy += constituent.Momentum().Et(); if (jet.DeltaRTo(constituent.Momentum()) < 0.2_rad) core_energy += constituent.Momentum().Et(); } return energy == 0_eV ? 0. : static_cast<double>(core_energy / energy); }
Angle JetInfo::TrackRadius(Jet const &jet) const { DEBUG0; auto energy = 0_eV; auto weight = 0_eV * rad; for (auto const &constituent : Constituents()) if (constituent.DetectorPart() == DetectorPart::track) { energy += constituent.Momentum().Et(); weight += constituent.Momentum().Et() * jet.DeltaRTo(constituent.Momentum()); } return energy == 0_eV ? 0_rad : Angle(weight / energy); }
Jet smearedJet(const Jet & origJet, unsigned mode) { if (origJet.getVarF("jn_genpt") <= 0) return origJet; //smearing factors are described in https://twiki.cern.ch/twiki/bin/view/CMS/JetResolution double eta = fabs(origJet.lorentzVector().Eta()); double pt = origJet.lorentzVector().Pt(); double ptSF = 1.0; double ptSF_err = 0.06; if (eta < 0.5) { ptSF = 1.052; ptSF_err = sqrt(pow(0.012, 2) + pow(0.5 * (0.062 + 0.061), 2)); } else if (eta >= 0.5 && eta < 1.1) { ptSF = 1.057; ptSF_err = sqrt(pow(0.012, 2) + pow(0.5 * (0.056 + 0.055), 2)); } else if (eta >= 1.1 && eta < 1.7) { ptSF = 1.096; ptSF_err = sqrt(pow(0.017, 2) + pow(0.5 * (0.063 + 0.062), 2)); } else if (eta >= 1.7 && eta < 2.3) { ptSF = 1.134; ptSF_err = sqrt(pow(0.035, 2) + pow(0.5 * (0.087 + 0.085),2)); } else if (eta >= 2.3 && eta < 5.0) { ptSF = 1.288; ptSF_err = sqrt(pow(0.127, 2) + pow(0.5 * (0.155 + 0.153), 2)); } if (mode == 1) ptSF += ptSF_err; else if (mode == 2) ptSF -= ptSF_err; ptSF = max(0., (origJet.getVarF("jn_genpt") + ptSF * (pt - origJet.getVarF("jn_genpt")))) / pt; //deterministic version if (ptSF <= 0) return origJet; double px = origJet.getVarF("jn_px") * ptSF; double py = origJet.getVarF("jn_py") * ptSF; double pz = origJet.getVarF("jn_pz"); double mass = origJet.lorentzVector().M(); double en = sqrt(mass * mass + px * px + py * py + pz * pz); Jet smearedJet(origJet); smearedJet.addFloatVar( "jn_px", px ); smearedJet.addFloatVar( "jn_py", py ); smearedJet.addFloatVar( "jn_pz", pz ); smearedJet.addFloatVar( "jn_en", en ); return smearedJet; }
double BTagWeight::getAverageUDSGEfficiency(const JetCollection& jets) const { std::vector<double> efficiencies; for (unsigned int index = 0; index < jets.size(); ++index) { const Jet jet(jets.at(index)); double efficiency(0); //these numbers are for CSVM only double pt = getSmearedJetPtScale(jet, 0)*jet.pt(); if (pt < 20) { continue; } else if (pt > 800) { efficiency = getMeanUDSGEfficiency(800.); } else { efficiency = getMeanUDSGEfficiency(pt); } efficiencies.push_back(efficiency); } double sumOfEfficiencies = std::accumulate(efficiencies.begin(), efficiencies.end(), 0.0); if (efficiencies.size() == 0) return 1.; else return sumOfEfficiencies / efficiencies.size(); }
double BTagWeight::getBScaleFactor(const Jet& jet, double uncertaintyFactor) const { const boost::array<double, 16> SFb_error = { {0.0554504, 0.0209663, 0.0207019, 0.0230073, 0.0208719, 0.0200453, 0.0264232, 0.0240102, 0.0229375, 0.0184615, 0.0216242, 0.0248119, 0.0465748, 0.0474666, 0.0718173, 0.0717567 } }; const boost::array<double, 16> ptbins = { {20, 30, 40, 50, 60, 70, 80,100, 120, 160, 210, 260, 320, 400, 500, 600 } }; double SFb(0); double sf_error(0); //these numbers are for CSVM only double pt = getSmearedJetPtScale(jet, 0)*jet.pt(); if (pt < 20) { SFb = 0.726981*((1.+(0.253238*20))/(1.+(0.188389*20))); sf_error = 0.12; } else if (pt > 800) { SFb = 0.726981*((1.+(0.253238*800))/(1.+(0.188389*800))); //use twice the uncertainty sf_error = 2 * SFb_error[SFb_error.size() - 1]; } else { SFb = 0.726981*((1.+(0.253238*pt))/(1.+(0.188389*pt))); unsigned int ptbin(0); for (unsigned int bin = 0; bin < ptbins.size() + 1; ++bin) { double upperCut = bin + 1 < ptbins.size() ? ptbins.at(bin + 1) : 800.; double lowerCut = ptbins.at(bin); if (pt > lowerCut && pt <= upperCut) { ptbin = bin; break; } } sf_error = SFb_error.at(ptbin); } SFb += sf_error * BJetSystematic_ * uncertaintyFactor; return SFb; }
Jet<Type> operator-(Jet<Type>& left, Jet<Type>& right) { if(left.length() != right.length() ) throw; // Krzycz o problemach Jet<Type> middle(left.length()); for(int i = 0; i < left.length(); i++) { middle.set(i, left.get(i) - right.get(i)); } return middle; }
Jet<Type> operator/(Jet<Type>& left, Jet<Type>& right) { if(left.length() != right.length() ) throw; // Krzycz o problemach Jet<Type> middle(left.length()); for(int i = 0; i < left.length(); i++) { Type acc = Type(); for(int j = 0; j <= i - 1; j ++) { acc += middle.get(j) * right.get(i-j); } middle.set(i, 1.0/right.get(0) * ( left.get(i) - acc ) ); } return middle; }
int main(int argc, const char *argv[]) try { GOOGLE_PROTOBUF_VERIFY_VERSION; if (2 > argc) { cerr << "Usage: " << argv[0] << " [events] output.pb" << endl; google::protobuf::ShutdownProtobufLibrary(); return 1; } { int events = 100; boost::shared_ptr<Writer> writer; if (3 == argc) { events = boost::lexical_cast<uint32_t>(argv[1]); writer.reset(new Writer(argv[2], 10000)); } else writer.reset(new Writer(argv[1])); writer->open(); if (writer->isOpen()) { writer->input()->set_type(Input::DATA); boost::shared_ptr<Event> event(new Event()); boost::shared_ptr<TRandom> randomizer(new TRandom3()); randomizer->SetSeed(time(0)); cout << "Generate: " << events << " events" << endl; for(int i = 0; events > i; ++i) { for(int pv = 0, pvs = randomizer->Poisson(2); pvs > pv; ++pv) { PrimaryVertex *pv = event->add_primary_vertices(); Vector *vertex = pv->mutable_vertex(); vertex->set_x(randomizer->Gaus(0, .3)); vertex->set_y(randomizer->Gaus(0, .5)); vertex->set_z(randomizer->Gaus(0, .7)); } for(int j = 0, jets = randomizer->Poisson(5); jets > j; ++j) { Jet *jet = event->add_jets(); LorentzVector *p4 = jet->mutable_physics_object()->mutable_p4(); p4->set_e(randomizer->Gaus(172, 10)); p4->set_px(randomizer->Gaus(100, 15)); p4->set_py(randomizer->Gaus(100, 20)); p4->set_pz(randomizer->Gaus(100, 25)); Vector *vertex = jet->mutable_physics_object()->mutable_vertex(); vertex->set_x(randomizer->Gaus(0, 5)); vertex->set_y(randomizer->Gaus(0, 4)); vertex->set_z(randomizer->Gaus(0, 3)); } for(int m = 0, muons = randomizer->Poisson(10); muons > m; ++m) { Muon *muon = event->add_pf_muons(); LorentzVector *p4 = muon->mutable_physics_object()->mutable_p4(); p4->set_e(randomizer->Gaus(.105, 0.005)); p4->set_px(randomizer->Gaus(10, 3)); p4->set_py(randomizer->Gaus(10, 2)); p4->set_pz(randomizer->Gaus(10, 1)); Vector *vertex = muon->mutable_physics_object()->mutable_vertex(); vertex->set_x(randomizer->Gaus(1, 2)); vertex->set_y(randomizer->Gaus(1, 3)); vertex->set_z(randomizer->Gaus(1, 4)); } writer->write(event); event->Clear(); } } } google::protobuf::ShutdownProtobufLibrary(); return 0; } catch(...) { cerr << "Unknown error" << endl; google::protobuf::ShutdownProtobufLibrary(); }
void JetEvaluator::fillOutputNtuples(PHCompositeNode *topNode) { if (Verbosity() > 2) cout << "JetEvaluator::fillOutputNtuples() entered" << endl; JetRecoEval* recoeval = _jetevalstack->get_reco_eval(); //JetTruthEval* trutheval = _jetevalstack->get_truth_eval(); //------------------------- // fill the reco jet ntuple //------------------------- if (_do_recojet_eval) { if (Verbosity() > 1) cout << "JetEvaluator::filling recojet ntuple..." << endl; JetMap* recojets = findNode::getClass<JetMap>(topNode,_recojetname.c_str()); if (!recojets) { cerr << PHWHERE << " ERROR: Can't find " << _recojetname << endl; exit(-1); } // for every recojet for (JetMap::Iter iter = recojets->begin(); iter != recojets->end(); ++iter) { Jet* recojet = iter->second; Jet* truthjet = recoeval->max_truth_jet_by_energy(recojet); float id = recojet->get_id(); float ncomp = recojet->size_comp(); float eta = recojet->get_eta(); float phi = recojet->get_phi(); float e = recojet->get_e(); float pt = recojet->get_pt(); float gid = NAN; float gncomp = NAN; float geta = NAN; float gphi = NAN; float ge = NAN; float gpt = NAN; float efromtruth = NAN; if (truthjet) { gid = truthjet->get_id(); gncomp = truthjet->size_comp(); geta = truthjet->get_eta(); gphi = truthjet->get_phi(); ge = truthjet->get_e(); gpt = truthjet->get_pt(); efromtruth = recoeval->get_energy_contribution(recojet,truthjet); } float recojet_data[14] = {(float) _ievent, id, ncomp, eta, phi, e, pt, gid, gncomp, geta, gphi, ge, gpt, efromtruth }; _ntp_recojet->Fill(recojet_data); } } //------------------------- // fill the truth jet ntuple //------------------------- if (_do_truthjet_eval) { if (Verbosity() > 1) cout << "JetEvaluator::filling truthjet ntuple..." << endl; JetMap* truthjets = findNode::getClass<JetMap>(topNode,_truthjetname.c_str()); if (!truthjets) { cerr << PHWHERE << " ERROR: Can't find " << _truthjetname << endl; exit(-1); } // for every truthjet for (JetMap::Iter iter = truthjets->begin(); iter != truthjets->end(); ++iter) { Jet* truthjet = iter->second; Jet* recojet = recoeval->best_jet_from(truthjet); float gid = truthjet->get_id(); float gncomp = truthjet->size_comp(); float geta = truthjet->get_eta(); float gphi = truthjet->get_phi(); float ge = truthjet->get_e(); float gpt = truthjet->get_pt(); float id = NAN; float ncomp = NAN; float eta = NAN; float phi = NAN; float e = NAN; float pt = NAN; float efromtruth = NAN; if (recojet) { id = recojet->get_id(); ncomp = recojet->size_comp(); eta = recojet->get_eta(); phi = recojet->get_phi(); e = recojet->get_e(); pt = recojet->get_pt(); efromtruth = recoeval->get_energy_contribution(recojet,truthjet); } float truthjet_data[14] = {(float) _ievent, gid, gncomp, geta, gphi, ge, gpt, id, ncomp, eta, phi, e, pt, efromtruth }; _ntp_truthjet->Fill(truthjet_data); } } return; }
double BTagEffService::GetEfficiency(BTagger const &bTagger, Jet const &jet) const { return GetEfficiency(bTagger, jet.Pt(), jet.Eta(), jet.Flavour(Jet::FlavourType::Hadron)); }
std::vector<Jet> Base::SubJets(Jet const& jet, int sub_jet_number) const { INFO0; auto cluster_sequence = ClusterSequence{jet.Constituents(), Settings::SubJetDefinition()}; return cluster_sequence.ExclusiveJetsUpTo(sub_jet_number); }
//void LeptonEnergy(const char *inputFile = "sourceFiles/LO/ttbar_LO_total.root") void LeptonEnergy(const TString & file) { //const char *inputFile = Form("/home/tjkim/work/pheno/topmass/sourceFiles/LO/fromSayaka/ttbar_%s.root",file.Data()); //gSystem->Load("/export/apps/delphes//libDelphes"); const char *inputFile = Form("/data/users/seohyun/analysis/ttbar_%s.root",file.Data()); gSystem->Load("/home/seohyun/delphes/libDelphes.so"); /* TFile *f2 = TFile::Open("weightfunc2.root"); TFile *f3 = TFile::Open("weightfunc3.root"); TFile *f5 = TFile::Open("weightfunc5.root"); TFile *f15 = TFile::Open("weightfunc15.root"); const int nmass = 151; float mymass[ nmass ]; float integral2[ nmass ]; float integral3[ nmass ]; float integral5[ nmass ]; float integral15[ nmass ]; for(int i=0; i < nmass ; i++){ integral2[i] = 0.0; integral3[i] = 0.0; integral5[i] = 0.0; integral15[i] = 0.0; } TGraph * g2[nmass]; TGraph * g3[nmass]; TGraph * g5[nmass]; TGraph * g15[nmass]; TIter next(f2->GetListOfKeys()); TKey *key; int i = 0; while( (key = (TKey*) next())) { TClass *cl = gROOT->GetClass( key->GetClassName()); if( !cl->InheritsFrom("TGraph")) continue; g2[i] = (TGraph*) key->ReadObj(); string mass = g2[i]->GetName(); float temp = atof(mass.c_str()); mymass[i] = temp; i++; } TIter next(f3->GetListOfKeys()); i = 0; while( (key = (TKey*) next())) { TClass *cl = gROOT->GetClass( key->GetClassName()); if( !cl->InheritsFrom("TGraph")) continue; g3[i] = (TGraph*) key->ReadObj(); i++; } TIter next(f5->GetListOfKeys()); i = 0; while( (key = (TKey*) next())) { TClass *cl = gROOT->GetClass( key->GetClassName()); if( !cl->InheritsFrom("TGraph")) continue; g5[i] = (TGraph*) key->ReadObj(); i++; } TIter next(f15->GetListOfKeys()); i = 0; while( (key = (TKey*) next())) { TClass *cl = gROOT->GetClass( key->GetClassName()); if( !cl->InheritsFrom("TGraph")) continue; g15[i] = (TGraph*) key->ReadObj(); i++; } TFile * res = TFile::Open("hist_LO_res_v3.root"); TH1F * h_acc = (TH1F*) res->Get("h_totalacc_lepton"); */ //TFile* f = TFile::Open("hist_LO_res_60.root", "recreate"); TFile* f = TFile::Open(Form("170717/hist_%s.root",file.Data()), "recreate"); // Create chain of root trees TChain chain("Delphes"); chain.Add(inputFile); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); // Get pointers to branches used in this analysis TClonesArray *branchParticle = treeReader->UseBranch("Particle"); TClonesArray *branchMuon = treeReader->UseBranch("Muon"); TClonesArray *branchElectron = treeReader->UseBranch("Electron"); TClonesArray *branchJet = treeReader->UseBranch("Jet"); TClonesArray *branchEvent = treeReader->UseBranch("Event"); GenParticle *particle; GenParticle *daughter1; GenParticle *daughter2; GenParticle *granddaughter1_1; GenParticle *granddaughter1_2; GenParticle *granddaughter2_1; GenParticle *granddaughter2_2; GenParticle *genelectron; GenParticle *genmuon; LHEFEvent * event; // Create TTree //Float_t Muon_E; //Float_t Electron_E; //Float_t Lepton_E; //Float_t Lepton_E_reco; //TTree * tree = new TTree("tree","lepton energy"); //tree->Branch("Lepton_E",&Lepton_E,"Lepton_E/F"); //tree->Branch("Lepton_E_reco",&Lepton_E_reco,"Lepton_E_reco/F"); //tree->Branch("Muon_E",&Muon_E,"Muon_E/F"); //tree->Branch("Electron_E",&Electron_E,"Electron_E/F"); // Book histograms TH1 * channel = new TH1F("channel", "ttbar event categorization", 7, 0.0, 7.0); TH1 * h_muon_energy = new TH1F("h_muon_energy", "muon energy distribution", 5000, 0, 500); TH1 * h_electron_energy = new TH1F("h_electron_energy", "electron energy distribution", 5000, 0, 500); TH1 * h_lepton_energy = new TH1F("h_lepton_energy", "lepton energy distribution", 5000, 0, 500); //TH1 * h_muon_energy_acc = new TH1F("h_muon_energy_acc", "muon energy distribution", 5000, 0, 500); //TH1 * h_electron_energy_acc = new TH1F("h_electron_energy_acc", "electron energy distribution", 5000, 0, 500); TH1 * h_lepton_energy_acc = new TH1F("h_lepton_energy_acc", "lepton energy distribution", 5000, 0, 500); //TH1 * h_muon_energy_reco = new TH1F("h_muon_energy_reco", "muon energy distribution at RECO", 5000, 0, 500); //TH1 * h_electron_energy_reco = new TH1F("h_electron_energy_reco", "electron energy distribution at RECO", 5000, 0, 500); TH1 * h_lepton_energy_reco = new TH1F("h_lepton_energy_reco", "lepton energy distribution at RECO", 5000, 0, 500); TH2 * h2_lepton_energy_response = new TH2F("h2_lepton_energy_response", "lepton energy response", 5000, 0, 500,5000,0,500); //TH1 * h_muon_energy_reco_S2 = new TH1F("h_muon_energy_reco_S2", "muon energy distribution at RECO", 5000, 0, 500); //TH1 * h_electron_energy_reco_S2 = new TH1F("h_electron_energy_reco_S2", "electron energy distribution at RECO", 5000, 0, 500); //TH1 * h_lepton_energy_reco_S2 = new TH1F("h_lepton_energy_reco_S2", "lepton energy distribution at RECO", 5000, 0, 500); //TH1 * h_lepton_nbjets_reco_S2 = new TH1F("h_lepton_nbjets_reco_S2","number of b jets",5,0,5); //TH1 * h_muon_energy_reco_final = new TH1F("h_muon_energy_reco_final", "muon energy distribution at RECO", 5000, 0, 500); //TH1 * h_electron_energy_reco_final = new TH1F("h_electron_energy_reco_final", "electron energy distribution at RECO", 5000, 0, 500); TH1 * h_lepton_energy_reco_final = new TH1F("h_lepton_energy_reco_final", "lepton energy distribution at RECO", 5000, 0, 500); TH2 * h2_lepton_energy_final_response = new TH2F("h2_lepton_energy_final_response", "lepton energy response", 5000, 0, 500,5000,0,500); //std::vector<float> lepton_E; //std::vector<float> lepton_E_final; int ndileptonic = 0; //ee, mm, tautau int ndileptonic2 = 0; //ee, mm, tau->ee, mm int ndileptonic3 = 0; //ee, mm int nsemileptonic = 0; int nsemileptonic2 = 0; int nsemileptonic3 = 0; int nhadronic = 0; // Loop over all events for(Int_t entry = 0; entry < numberOfEntries; ++entry) { //if( entry == 100000) break; if( entry%1000 == 0) cout << "starting with " << entry << endl; // Load selected branches with data from specified event treeReader->ReadEntry(entry); int nmuons = 0; int nelectrons= 0; int ntaumuons = 0; int ntauelectrons= 0; int ntaus = 0 ; int nhadrons = 0 ; // If event contains at least 1 particle int ntop = 0; double genweight = 1.0; if(branchEvent->GetEntries() > 0) { event = (LHEFEvent * ) branchEvent->At(0); genweight = event->Weight; //cout << "event number = " << event->Number << endl; //cout << "event weight = " << event->Weight << endl; } //Lepton_E = -1.0; if(branchParticle->GetEntries() > 0) { for(int i = 0; i < branchParticle->GetEntriesFast() ; i++){ if(ntop == 2) break; particle = (GenParticle *) branchParticle->At(i); int status = particle->Status; bool LO = true; //if( LO ) cout << "THIS IS LO..." << endl; if( status != 3) continue; int id = particle->PID; double gen_pt = particle->PT; double gen_eta = particle->Eta; //Leading order if( LO) { if( abs(id) == 11 ){ genelectron = particle; double energy = genelectron->E; h_electron_energy->Fill( energy, genweight ); h_lepton_energy->Fill( energy, genweight ); //Lepton_E = energy; //for(int i=0; i < nmass; i++){ // float w = g2[i]->Eval( energy ); // integral2[i] = integral2[i] + w ; //} //lepton_E.push_back( energy ); if( energy > 20 && fabs(gen_eta) < 2.4) { //h_electron_energy_acc->Fill( energy, genweight ); h_lepton_energy_acc->Fill( energy, genweight ); nmuons++; } //daughter1 = (GenParticle*) branchParticle->At( particle->D1); //daughter2 = (GenParticle*) branchParticle->At( particle->D2); //int d1_id = abs(daughter1->PID); //int d2_id = abs(daughter2->PID); //cout << "electron daughter " << d1_id << " , " << d2_id << endl; }else if( abs(id) == 13 ){ genmuon = particle; double energy = genmuon->E; h_muon_energy->Fill( energy, genweight ); h_lepton_energy->Fill( energy, genweight ); //Lepton_E = energy; //for(int i=0; i < nmass; i++){ // float w = g2[i]->Eval( energy ); // integral2[i] = integral2[i] + w ; //} //lepton_E.push_back( energy ); if( energy > 20 && fabs(gen_eta) < 2.4) { //h_muon_energy_acc->Fill( energy, genweight ); h_lepton_energy_acc->Fill( energy, genweight ); nelectrons++; } //int d1_id = -1; //int d2_id = -1; //if( particle->D1 >= branchParticle->GetEntries()){ // daughter1 = (GenParticle*) branchParticle->At( particle->D1); // int d1_id = abs(daughter1->PID); //} //if( particle->D1 >= branchParticle->GetEntries()){ // daughter1 = (GenParticle*) branchParticle->At( particle->D1); // int d1_id = abs(daughter1->PID); //} //cout << "muon daughter " << d1_id << " , " << d2_id << endl; } //NLO }else if( abs(id) == 6 ) { ntop++; particle = (GenParticle*) branchParticle->At( i ) ; if( particle->D1 >= branchParticle->GetEntries() ) continue; bool lasttop = false ; while( !lasttop ){ if( particle->D1 >= branchParticle->GetEntries() ) break; GenParticle * d = (GenParticle *) branchParticle->At( particle->D1 ); if( abs(d->PID) != 6 ) { lasttop = true; } else { particle = d ; } } if( particle->D1 >= branchParticle->GetEntries() || particle->D2 >= branchParticle->GetEntries() ){ continue; } daughter1 = (GenParticle*) branchParticle->At( particle->D1) ; daughter2 = (GenParticle*) branchParticle->At( particle->D2) ; bool lastW = false; int d1_id = abs(daughter1->PID); int d2_id = abs(daughter2->PID); //cout << "top daughter " << d1_id << " , " << d2_id << endl; while( !lastW) { if( daughter1->D1 >= branchParticle->GetEntries() ) break; GenParticle * d = (GenParticle *) branchParticle->At( daughter1->D1 ); if( abs(d->PID) != 24 ) { lastW = true; } else { daughter1 = d ; } } if( daughter1->D1 >= branchParticle->GetEntries() || daughter1->D2 >= branchParticle->GetEntries() ){ continue; } granddaughter1_1 = (GenParticle*) branchParticle->At( daughter1->D1) ; granddaughter1_2 = (GenParticle*) branchParticle->At( daughter1->D2) ; granddaughter2_1 = (GenParticle*) branchParticle->At( daughter2->D1) ; granddaughter2_2 = (GenParticle*) branchParticle->At( daughter2->D2) ; int gd1_1_id = abs(granddaughter1_1->PID); int gd1_2_id = abs(granddaughter1_2->PID); int gd2_1_id = abs(granddaughter2_1->PID); int gd2_2_id = abs(granddaughter2_2->PID); //cout << "W daughters = " << gd1_1_id << " , " << gd1_2_id << " , " << gd2_1_id << " , " << gd2_2_id << endl; int W_dau_status = granddaughter1_1->Status ; //if( gd1_1_id > gd1_2_id ) cout << "Something is WRONG ! " << endl; GenParticle * le = (GenParticle * ) branchParticle->At( granddaughter1_1->D1 ); //GenParticle * leda = (GenParticle * ) branchParticle->At( le->D1); if( gd1_1_id == 11 || gd1_1_id == 13 ){ cout << le->D1 << " , " << le->D2 << endl; // cout << " original id and status = " << gd1_1_id << " , " << W_dau_status << " le id and status = " << le->PID << " , " << le->Status << " leda id and status = " << leda->PID << " , " << leda->Status << endl; } if( gd1_1_id == 11 ) { nelectrons++; //genelectron = granddaughter1_2; genelectron = le; } else if( gd1_1_id == 13 ) { nmuons++; //genmuon = granddaughter1_2; genmuon = le; } else if( gd1_1_id == 15 ) { ntaus++; /* if( granddaughter1_2->D1 >= branchParticle->GetEntries() || granddaughter1_2->D2 >= branchParticle->GetEntries() ){ continue; } GenParticle * taudaughter1 = (GenParticle*) branchParticle->At( granddaughter1_2->D1) ; GenParticle * taudaughter2 = (GenParticle*) branchParticle->At( granddaughter1_2->D2) ; int taud1_id = abs(taudaughter1->PID); int taud2_id = abs(taudaughter2->PID); //cout << "tau daughter = " << taud1_id << " " << taud2_id << endl; if( taud1_id == 11 || taud1_id == 12 ) ntauelectrons++; else if( taud1_id == 13 || taud1_id == 14 ) ntaumuons++; else if( taud1_id == 15 || taud1_id == 16 ) { if( taudaughter1->D1 >= branchParticle->GetEntries() || taudaughter1->D2 >= branchParticle->GetEntries() ){ continue; } GenParticle * taugranddaughter1 = (GenParticle*) branchParticle->At( taudaughter1->D1) ; GenParticle * taugranddaughter2 = (GenParticle*) branchParticle->At( taudaughter1->D2) ; int taugd1_id = abs(taugranddaughter1->PID); int taugd2_id = abs(taugranddaughter2->PID); //cout << "tau grand daughter = " << taugd1_id << " " << taugd2_id << endl; if( taugd1_id == 11 || taugd1_id == 12 ) ntauelectrons++; else if( taugd1_id == 13 || taugd1_id == 14 ) ntaumuons++; ㅜㅜ else { continue; } } else { continue; } */ }else{ nhadrons++; } //cout << "nelectrons = " << nelectrons << " nmuons = " << nmuons << " ntaus = " << ntaus << " nhadrons = " << nhadrons << endl; } } } if( LO ){ }else{ int remaining = 0 ; int nleptons = nelectrons + nmuons + ntaus; if( nleptons == 2 && nhadrons == 0){ //cout << "dilepton" << endl; ndileptonic++; if( ntaus ==0 || ( ntaus == 1 && (ntauelectrons+ntaumuons) == 1) || (ntaus == 2 && (ntauelectrons+ntaumuons) == 2) ) { ndileptonic2++; } if( ntaus == 0) ndileptonic3++; }else if( nleptons == 1 && nhadrons == 1){ //cout << "lepton+jets" << endl; nsemileptonic++; if( ntaus ==0 || ( ntaus == 1 && (ntauelectrons+ntaumuons) == 1) ) nsemileptonic2++; if( ntaus == 0 ) { nsemileptonic3++; if( nmuons ) { h_muon_energy->Fill(genmuon->E, genweight); h_lepton_energy->Fill(genmuon->E, genweight); } if( nelectrons ) { h_electron_energy->Fill(genelectron->E, genweight); h_lepton_energy->Fill(genelectron->E, genweight); } } }else if ( nleptons == 0 && nhadrons == 2 ){ //cout << "hadronic" << endl; nhadronic++; }else{ //cout << "remaining" << endl; remaining++; } } Muon * mymuon; Electron * myelectron; bool passmuon = false; bool passelectron = false; if(branchMuon->GetEntries() > 0) { bool mymuonpass = false; for(int i = 0; i < branchMuon->GetEntriesFast() ; i++){ Muon * muon = (Muon *) branchMuon->At(i); if( muon->P4().E() > 20 && fabs( muon->P4().Eta() < 2.4) ){ mymuon = muon; mymuonpass = true; } break; } if( mymuonpass && ( nmuons > 0 || nelectrons > 0 ) ){ //h_muon_energy_reco->Fill(mymuon->P4().E(), genweight); h_lepton_energy_reco->Fill(mymuon->P4().E(), genweight); h2_lepton_energy_response->Fill(mymuon->P4().E(), genmuon->E, genweight); passmuon = true; } } if(branchElectron->GetEntries() > 0) { bool myelectronpass = false; for(int i = 0; i < branchElectron->GetEntriesFast() ; i++){ Electron * electron = (Electron *) branchElectron->At(i); if( electron->P4().E() > 20 && fabs( electron->P4().Eta() < 2.4) ){ myelectron = electron; myelectronpass = true; } break; } if( myelectronpass && ( nmuons > 0 || nelectrons > 0 ) ){ //h_electron_energy_reco->Fill(myelectron->P4().E(), genweight); h_lepton_energy_reco->Fill(myelectron->P4().E(), genweight); h2_lepton_energy_response->Fill(myelectron->P4().E(), genelectron->E, genweight); passelectron = true; } } if(branchJet->GetEntries() > 0 ) { int njets = 0; int nbjets = 0; for(int i = 0; i < branchJet->GetEntriesFast() ; i++){ Jet * jet = (Jet *) branchJet->At(i); if( jet->P4().Pt() > 30 && fabs( jet->P4().Eta() < 2.5) ){ njets++; if( jet->BTag ) nbjets++; } } } //Muon_E = -9.0; //Electron_E = -9.0; //Lepton_E_reco = -1.0; float Energy = 9.0; if( passelectron && !passmuon && njets >= 4){ float myele_energy = myelectron->P4().E(); //h_electron_energy_reco_S2->Fill(myele_energy, genweight); //h_lepton_energy_reco_S2->Fill(myele_energy, genweight); //h_lepton_nbjets_reco_S2->Fill(nbjets); if( nbjets >= 2 ){ //h_electron_energy_reco_final->Fill(myele_energy, genweight); h_lepton_energy_reco_final->Fill(myele_energy, genweight); h2_lepton_energy_final_response->Fill(myele_energy, genelectron->E, genweight); } //lepton_E_final.push_back( myelectron->P4().E() ); //for(int i=0; i < nmass; i++){ // float corr = 1.0/ h_acc->Interpolate( myelectron->P4().E() ); // float w = g2[i]->Eval( myelectron->P4().E() ); //integral2[i] = integral2[i] + w*corr ; //} //Electron_E = myele_energy; //Lepton_E_reco = myele_energy; } if( passmuon && !passelectron && njets >= 4){ float mymuon_energy = mymuon->P4().E(); //h_muon_energy_reco_S2->Fill(mymuon_energy, genweight); //h_lepton_energy_reco_S2->Fill(mymuon_energy, genweight); //h_lepton_nbjets_reco_S2->Fill(nbjets); if( nbjets >= 2 ){ // h_muon_energy_reco_final->Fill(mymuon_energy, genweight); h_lepton_energy_reco_final->Fill(mymuon_energy, genweight); h2_lepton_energy_final_response->Fill(mymuon_energy, genmuon->E, genweight); } //lepton_E_final.push_back( mymuon->P4().E() ); //for(int i=0; i < nmass; i++){ // float corr = 1.0/ h_acc->Interpolate( mymuon->P4().E() ); // float w = g2[i]->Eval( mymuon->P4().E() ); //integral2[i] = integral2[i] + w*corr ; //} //Muon_E = mymuon_energy; //Lepton_E_reco = mymuon_energy; } /* for(int i=0; i < nmass; i++){ //for(int i=0; i < 0; i++){ float lenergy = -9; if( Muon_E > 0 && Electron_E < 0 ) lenergy = Muon_E; if( Muon_E < 0 && Electron_E > 0 ) lenergy = Electron_E; float acc = h_acc->Interpolate( lenergy ); integral2[i] = integral2[i] + g2[i]->Eval( lenergy ) /acc ; integral3[i] = integral3[i] + g3[i]->Eval( lenergy ) /acc ; integral5[i] = integral5[i] + g5[i]->Eval( lenergy ) /acc ; integral15[i] = integral15[i] + g15[i]->Eval( lenergy ) /acc ; } */ //if( passmuon && passelectron) cout << "Lepton E = " << Lepton_E << endl; //tree->Fill(); } //tree->Print(); // for(int m=0; m < nmass; m++){ // for(int i=0; i < 400;i++){ // float bincenter = h_lepton_energy->GetBinCenter(i+1); // float binconten = h_lepton_energy->GetBinContent(i+1); // float weight_value = g2[m]->Eval( bincenter ); // integral2[m] = integral2[m] + weight_value*binconten; // } // } /* for(int m=0; m < nmass; m++){ for(int i=0; i < lepton_E_final.size() ;i++){ float energy = lepton_E_final[i]; float corr = 1.0/ h_acc->Interpolate( energy ); float weight_value2 = g2[m]->Eval( bincenter ); float weight_value3 = g3[m]->Eval( bincenter ); float weight_value5 = g5[m]->Eval( bincenter ); float weight_value15 = g15[m]->Eval( bincenter ); integral2[m] = integral2[m] + weight_value2*corr; integral3[m] = integral3[m] + weight_value3*corr; integral5[m] = integral5[m] + weight_value5*corr; integral15[m] = integral15[m] + weight_value15*corr; } } TGraph * final2 = new TGraph(); TGraph * final3 = new TGraph(); TGraph * final5 = new TGraph(); TGraph * final15 = new TGraph(); for (Int_t i=0;i<nmass;i++) { final2->SetPoint(i, mymass[i], integral2[i]); final3->SetPoint(i, mymass[i], integral3[i]); final5->SetPoint(i, mymass[i], integral5[i]); final15->SetPoint(i, mymass[i], integral15[i]); } final2->SetName("n2"); final3->SetName("n3"); final5->SetName("n5"); final15->SetName("n15"); final2->Write(); final3->Write(); final5->Write(); final15->Write(); */ if( remaining != 0 ) cout << "Someting is wrong" << endl; //TCanvas * c = new TCanvas("c","c",1000,600); channel->SetBinContent(1,ndileptonic); channel->SetBinContent(2,ndileptonic2); channel->SetBinContent(3,ndileptonic3); channel->SetBinContent(4,nsemileptonic); channel->SetBinContent(5,nsemileptonic2); channel->SetBinContent(6,nsemileptonic3); channel->SetBinContent(7,nhadronic); channel->GetXaxis()->SetBinLabel(1,"Dileptonic"); channel->GetXaxis()->SetBinLabel(2,"DileptonicTau"); channel->GetXaxis()->SetBinLabel(3,"DileptonicNoTau"); channel->GetXaxis()->SetBinLabel(4,"Semileptonic"); channel->GetXaxis()->SetBinLabel(5,"SemileptonicTau"); channel->GetXaxis()->SetBinLabel(6,"SemileptonicNoTau"); channel->GetXaxis()->SetBinLabel(7,"Hadronic"); //int nBins = 400; //h_lepton_energy->AddBinContent(nBins, h_lepton_energy->GetBinContent(nBins+1)); //h_lepton_energy_reco_final->AddBinContent(nBins, h_lepton_energy_reco_final->GetBinContent(nBins+1)); // Show resulting histograms channel->SetStats(0000); double scale = 1.0/numberOfEntries; channel->Scale( scale ); //channel->Draw("HText0"); /* channel->Write(); h_muon_energy->Write(); h_electron_energy->Write(); h_lepton_energy->Write(); h_muon_energy_acc->Write(); h_electron_energy_acc->Write(); h_lepton_energy_acc->Write(); h_muon_energy_reco->Write(); h_electron_energy_reco->Write(); h_lepton_energy_reco->Write(); h_muon_energy_reco_final->Write(); h_electron_energy_reco_final->Write(); h_lepton_energy_reco_final->Write(); */ f->Write(); f->Close(); }
void AnalyseEvents(ExRootTreeReader *treeReader, TestPlots *plots) { TClonesArray *branchParticle = treeReader->UseBranch("Particle"); TClonesArray *branchElectron = treeReader->UseBranch("Electron"); TClonesArray *branchMuon = treeReader->UseBranch("Muon"); TClonesArray *branchPhoton = treeReader->UseBranch("Photon"); TClonesArray *branchEFlowTrack = treeReader->UseBranch("EFlowTrack"); TClonesArray *branchEFlowTower = treeReader->UseBranch("EFlowTower"); TClonesArray *branchEFlowMuon = treeReader->UseBranch("EFlowMuon"); TClonesArray *branchJet = treeReader->UseBranch("Jet"); Long64_t allEntries = treeReader->GetEntries(); cout << "** Chain contains " << allEntries << " events" << endl; GenParticle *particle; Electron *electron; Photon *photon; Muon *muon; Track *track; Tower *tower; Jet *jet; // P4 returns a TLorentzVector TObject *object; TLorentzVector momentum; Float_t Eem, Ehad; Bool_t skip; Long64_t entry; Int_t i, j, pdgCode; // Loop over all events for(entry = 0; entry < allEntries; entry++) { // Load selected branches with data from specified event treeReader->ReadEntry(entry); ///---- take the two highest pt leptons in the event (m or e) // maps are ordered in ascending order std::map <float, int> m_maxptleptons; // Loop over all electrons in event for(i = 0; i < branchElectron->GetEntriesFast(); i++) { electron = (Electron*) branchElectron->At(i); double pt = electron->PT; m_maxptleptons[-pt] = -(i+1); } // Loop over all muons in event for(i = 0; i < branchMuon->GetEntriesFast(); i++) { muon = (Muon*) branchMuon->At(i); double pt = muon->PT; m_maxptleptons[-pt] = (i+1); } //---- at least 2 leptons ---- if (m_maxptleptons.size() < 2) continue; // kind = 0/1 if m/e std::map<float, int>::iterator it_type_m_lepton = m_maxptleptons.begin(); int flav1 = (it_type_m_lepton->second<0); // m>0, e<0 ---> m=0, e=1 plots->hpt1->Fill(- it_type_m_lepton->first); it_type_m_lepton++; int flav2 = (it_type_m_lepton->second<0); // m>0, e<0 ---> m=0, e=1 plots->hpt2->Fill(- it_type_m_lepton->first); int nlep = 0; for(it_type_m_lepton = m_maxptleptons.begin(); it_type_m_lepton != m_maxptleptons.end(); it_type_m_lepton++) { if ( -(it_type_m_lepton->first) > 10) nlep++; } plots->hnleppt10->Fill(nlep); // ee/mm e m m e plots->hchannel->Fill(flav1*flav2+2*(flav1>flav2)+3*(flav1<flav2)); // # mumu # channel == 0 // # mue # channel == 3 // # emu # channel == 2 // # ee # channel == 1 TLorentzVector l1, l2; it_type_m_lepton = m_maxptleptons.begin(); if (it_type_m_lepton->second>0) { l1 = ((Muon*) branchMuon->At( it_type_m_lepton->second - 1 ))->P4();} else { l1 = ((Electron*) branchElectron->At(-(it_type_m_lepton->second + 1)))->P4();} it_type_m_lepton++; if (it_type_m_lepton->second>0) { l2 = ((Muon*) branchMuon->At( it_type_m_lepton->second - 1 ))->P4();} else { l2 = ((Electron*) branchElectron->At(-(it_type_m_lepton->second + 1)))->P4();} plots->hmll->Fill((l1+l2).M()); plots->hdphill->Fill( l1.DeltaPhi(l2) ); // Loop over all jets in event //---- two highest mjj are VBF jets //---- the other two are "H>bb" jets //---- at least 4 jets with pt>MINPTJET GeV float MINPTJET = 15.; int countJets = 0; for(i = 0; i < branchJet->GetEntriesFast(); i++) { jet = (Jet*) branchJet->At(i); TLorentzVector jetP4 = jet->P4(); if (jet->PT > MINPTJET && !isThisJetALepton(jetP4, l1, l2)) countJets++; } if (countJets < 4) { continue; } TLorentzVector jet1, jet2, jet3, jet4; TLorentzVector Jet1, Jet2, bJet1, bJet2; //---- the VBF jets and the H>bb jets int ijet = 0; for(i = 0; i < branchJet->GetEntriesFast(); i++) { jet = (Jet*) branchJet->At(i); TLorentzVector jetP4 = jet->P4(); if (jet->PT > MINPTJET && !isThisJetALepton(jetP4, l1, l2)) { if (ijet == 0) {jet1 = jetP4; ijet++; } else if (ijet == 1) {jet2 = jetP4; ijet++; } else if (ijet == 2) {jet3 = jetP4; ijet++; } else if (ijet == 3) {jet4 = jetP4; ijet++; } } } if (jet4.Pt() < MINPTJET) { std::cout << "We have a problem; countJets = " << countJets << "; ijet = " << ijet << " and jet4.Pt() = " << jet4.Pt() << std::endl; } float mjj12 = (jet1+jet2).M(); float mjj13 = (jet1+jet3).M(); float mjj14 = (jet1+jet4).M(); float mjj23 = (jet2+jet3).M(); float mjj24 = (jet2+jet4).M(); float mjj34 = (jet3+jet4).M(); std::map<float, int> m_maxmjj; m_maxmjj[-mjj12] = 1; m_maxmjj[-mjj13] = 2; m_maxmjj[-mjj14] = 3; m_maxmjj[-mjj23] = 4; m_maxmjj[-mjj24] = 5; m_maxmjj[-mjj34] = 6; std::map<float, int>::iterator it_type_m_maxmjj = m_maxmjj.begin(); plots->hmjj->Fill( - it_type_m_maxmjj->first ); if (it_type_m_maxmjj->second == 1) { Jet1 = jet1; Jet2 = jet2; bJet1 = jet3; bJet2 = jet4; }; if (it_type_m_maxmjj->second == 2) { Jet1 = jet1; Jet2 = jet3; bJet1 = jet2; bJet2 = jet4; }; if (it_type_m_maxmjj->second == 3) { Jet1 = jet1; Jet2 = jet4; bJet1 = jet2; bJet2 = jet3; }; if (it_type_m_maxmjj->second == 4) { Jet1 = jet2; Jet2 = jet3; bJet1 = jet1; bJet2 = jet4; }; if (it_type_m_maxmjj->second == 5) { Jet1 = jet2; Jet2 = jet4; bJet1 = jet1; bJet2 = jet3; }; if (it_type_m_maxmjj->second == 6) { Jet1 = jet3; Jet2 = jet4; bJet1 = jet1; bJet2 = jet2; }; //---- sub-order in pt if (Jet1.Pt() < Jet2.Pt()) { TLorentzVector tempjet = Jet1; Jet1 = Jet2; Jet2 = tempjet; } if (bJet1.Pt() < bJet2.Pt()) { TLorentzVector tempjet = bJet1; bJet1 = bJet2; bJet2 = tempjet; } plots->hmbb->Fill( (bJet1+bJet2).M() ); plots->hbjetpt1->Fill( bJet1.Pt() ); plots->hbjetpt2->Fill( bJet2.Pt() ); plots->hjetpt1->Fill( Jet1.Pt() ); plots->hjetpt2->Fill( Jet2.Pt() ); // std::cout << " it_type_m_lepton->first = " << it_type_m_lepton->first << std::endl; // plots->hpt1->Fill(m_maxptleptons.begin()->first); // typedef std::map<float, int>::iterator it_type_m_lepton; // for(it_type iterator = m.begin(); iterator != m.end(); iterator++) { // plots->hpt1->Fill(v_maxptleptons.at(0).first); // Loop over all tracks in event for(i = 0; i < branchEFlowTrack->GetEntriesFast(); i++) { // track = (Track*) branchEFlowTrack->At(i); // particle = (GenParticle*) track->Particle.GetObject(); // // plots->fTrackDeltaPT->Fill((particle->PT - track->PT)/particle->PT); // plots->fTrackDeltaEta->Fill((particle->Eta - track->Eta)/particle->Eta); } // Loop over all towers in event for(i = 0; i < branchEFlowTower->GetEntriesFast(); i++) { // tower = (Tower*) branchEFlowTower->At(i); // v_maxptleptons // Eem = 0.0; // Ehad = 0.0; // skip = kFALSE; // for(j = 0; j < tower->Particles.GetEntriesFast(); ++j) // { // particle = (GenParticle*) tower->Particles.At(j); // pdgCode = TMath::Abs(particle->PID); // // // skip muons and neutrinos // if(pdgCode == 12 || pdgCode == 13 || pdgCode == 14 || pdgCode == 16) // { // continue; // } // // // skip K0short and Lambda // if(pdgCode == 310 || pdgCode == 3122) // { // skip = kTRUE; // } // // if(pdgCode == 11 || pdgCode == 22) // { // // Eem += particle->E; // } // else // { // Ehad += particle->E; // } // } // if(skip) continue; // if(Eem > 0.0 && tower->Eem > 0.0) plots->fTowerDeltaEem->Fill((Eem - tower->Eem)/Eem); // if(Ehad > 0.0 && tower->Ehad > 0.0) plots->fTowerDeltaEhad->Fill((Ehad - tower->Ehad)/Ehad); } // Loop over all jets in event for(i = 0; i < branchJet->GetEntriesFast(); i++) { // jet = (Jet*) branchJet->At(i); // // momentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0); // // // Loop over all jet's constituents // for(j = 0; j < jet->Constituents.GetEntriesFast(); ++j) // { // object = jet->Constituents.At(j); // // // Check if the constituent is accessible // if(object == 0) continue; // // if(object->IsA() == GenParticle::Class()) // { // momentum += ((GenParticle*) object)->P4(); // } // else if(object->IsA() == Track::Class()) // { // momentum += ((Track*) object)->P4(); // } // else if(object->IsA() == Tower::Class()) // { // momentum += ((Tower*) object)->P4(); // } // else if(object->IsA() == Muon::Class()) // { // momentum += ((Muon*) object)->P4(); // } // } // plots->fJetDeltaPT->Fill((jet->PT - momentum.Pt())/jet->PT ); // } } } }
void JESBDTVars::FillBranches(EventContainer * evtObj){ //Evaluate each distribution once per JES shift for (int i = 0; i < evtObj->jets[0].GetNumberOfJESCorrections(); i++){ //First let's clear the things we already have selectedJet.clear(); Jet2040.clear(); BJet.clear(); UntaggedJet.clear(); //And make a dummy variable here Jet tempJet; TLorentzVector tempjet(0,0,0,0); //Number of loose jets for (auto jet : evtObj->alljets){ tempJet = jet; TLorentzVector tempmet(0,0,0,0); tempJet.ShiftPtWithJESCorr(i,&tempmet); if (tempJet.Pt() > 20 && tempJet.Pt() < 40) Jet2040.push_back(tempJet); } for (auto jet : evtObj->jesShiftedJets[i]){ selectedJet.push_back(jet); if (jet.IsTagged()) BJet.push_back(jet); else UntaggedJet.push_back(jet); } //Now set up the lepton and met variables TLorentzVector Lepton(00,0,0,0); TLorentzVector Miss(00,0,0,0); TLorentzVector Wlv(0,0,0,0); Miss = evtObj->metVecsJESShifted[i]; if (evtObj->electronsToUsePtr->size() > 0){ // if this number is >0 we're in the electron channel. Otherwise use muons Lepton.SetPtEtaPhiE(evtObj->electronsToUsePtr->at(0).Pt(),evtObj->electronsToUsePtr->at(0).Eta(),evtObj->electronsToUsePtr->at(0).Phi(),evtObj->electronsToUsePtr->at(0).E()); } else{ Lepton.SetPtEtaPhiE(evtObj->muonsToUsePtr->at(0).Pt(),evtObj->muonsToUsePtr->at(0).Eta(),evtObj->muonsToUsePtr->at(0).Phi(),evtObj->muonsToUsePtr->at(0).E()); } Wlv = Lepton+Miss; TLorentzVector W(0,0,0,0), Top(0,0,0,0); for (auto jet : UntaggedJet){ W = W + jet; } TLorentzVector totalJets(0,0,0,0); for (auto jet : selectedJet){ totalJets += jet; } //That should be all of the things we need to make the BDT variables, so let's make the variables now. _floatVecVars["M_DeltaRBJetLepton_JESShifts"][i] = fabs(BJet[0].DeltaR(Lepton)); if (UntaggedJet.size() > 1) _floatVecVars["M_DeltaRlightjets_JESShifts"][i] = UntaggedJet.at(0).DeltaR(UntaggedJet.at(1)); if (BJet[0].DeltaR(Lepton) > BJet[0].DeltaR(W)){ _floatVecVars["M_topMass2_lep_JESShifts"][i] = -1; } else{ Top = W + BJet[0]; _floatVecVars["M_topMass2_lep_JESShifts"][i] = Top.M(); } _floatVecVars["M_Pt_Lepton_JESShifts"][i] = Lepton.Pt(); _floatVecVars["M_Pt_AllJetsLeptonMET_JESShifts"][i] = (Lepton + Miss + totalJets).Pt(); _floatVecVars["M_DeltaRLeptonJet1_JESShifts"][i] = fabs(selectedJet.at(0).DeltaR(Lepton)); if (selectedJet.size() > 2) _floatVecVars["M_Mass_Jet1Jet2Jet3LeptonMET_JESShifts"][i] = (selectedJet[0] + selectedJet[1] + selectedJet[2]).M(); _floatVecVars["M_hadronicWmass_JESShifts"][i] = W.M(); _floatVecVars["lightJet1CSV_JESShifts"][i] = UntaggedJet[0].GetbDiscriminator(); } }
int LeptoquarksReco::AddJetInformation( type_map_tcan& tauCandidateMap, JetMap* recojets, type_map_cdata* map_calotower ) { /* Loop over tau candidates */ for (type_map_tcan::iterator iter = tauCandidateMap.begin(); iter != tauCandidateMap.end(); ++iter) { Jet* jetx = recojets->get( (iter->second)->get_property_uint( PidCandidate::jet_id ) ); /* calculate transverse mass of jet */ float jet_mtrans = sqrt( pow( jetx->get_mass(), 2 ) + pow( jetx->get_pt(), 2 ) ); /* count jet ncomp above thresholds */ unsigned int jet_ncomp_above_0p1 = 0; unsigned int jet_ncomp_above_1 = 0; unsigned int jet_ncomp_above_10 = 0; for (Jet::ConstIter jcompiter = jetx->begin_comp(); jcompiter != jetx->end_comp(); ++jcompiter) { RawTowerDefs::CalorimeterId calo_id = RawTowerDefs::NONE; switch ( jcompiter->first ) { case Jet::CEMC_TOWER: calo_id = RawTowerDefs::CEMC; break; case Jet::HCALIN_TOWER: calo_id = RawTowerDefs::HCALIN; break; case Jet::HCALOUT_TOWER: calo_id = RawTowerDefs::HCALOUT; break; default: break; } /* continue if no calorimeter id found */ if ( calo_id == RawTowerDefs::NONE ) continue; /* get tower container from map, find tower in tower container, get tower energy */ float e_component = 0; if ( map_calotower->find( calo_id ) != map_calotower->end() ) e_component = ( ( ( map_calotower->find( calo_id ) )->second ).first )->getTower( jcompiter->second )->get_energy(); /* check if energy is above threshold and count up matching counters accordingly */ if ( e_component > 0.1 ) jet_ncomp_above_0p1++; if ( e_component > 1 ) jet_ncomp_above_1++; if ( e_component > 10 ) jet_ncomp_above_10++; } /* set tau candidate jet properties */ (iter->second)->set_property( PidCandidate::jet_eta , jetx->get_eta() ); (iter->second)->set_property( PidCandidate::jet_phi , jetx->get_phi() ); (iter->second)->set_property( PidCandidate::jet_etotal , jetx->get_e() ); (iter->second)->set_property( PidCandidate::jet_etrans , jetx->get_et() ); (iter->second)->set_property( PidCandidate::jet_ptotal , jetx->get_p() ); (iter->second)->set_property( PidCandidate::jet_ptrans , jetx->get_pt() ); (iter->second)->set_property( PidCandidate::jet_minv , jetx->get_mass() ); (iter->second)->set_property( PidCandidate::jet_mtrans , jet_mtrans ); (iter->second)->set_property( PidCandidate::jet_ncomp , (uint)jetx->size_comp() ); (iter->second)->set_property( PidCandidate::jet_ncomp_above_0p1 , jet_ncomp_above_0p1 ); (iter->second)->set_property( PidCandidate::jet_ncomp_above_1 , jet_ncomp_above_1 ); (iter->second)->set_property( PidCandidate::jet_ncomp_above_10 , jet_ncomp_above_10 ); (iter->second)->set_property( PidCandidate::jet_ncomp_emcal , (uint)jetx->count_comp( Jet::CEMC_TOWER ) ); } return 0; }
void fillPlots ( CollectionPtr & jets, CollectionPtr & core_jets, CollectionPtr & partons, CollectionPtr & hgceeClusters, CollectionPtr & hgchefClusters, CollectionPtr & hgchebClusters, likelihoodGetter & l, int index, std::vector<TH1F*> quark_th1, std::vector<TH1F*> gluon_th1, std::vector<TH2F*> quark_th2, std::vector<TH2F*> gluon_th2 ){ int n_jets = jets -> GetSize(); std::vector<double> likelihood_variables; for (int i = 0; i < n_jets; ++i){ Jet jet = jets -> GetConstituent<Jet>(i); CollectionPtr all_core_jets = core_jets; CollectionPtr matched_core_jets = core_jets -> SkimByRequireDRMatch<PFCoreJet, PFPrunedJet>( jet, 0.3 ) ; rechit_type my_type = NO_TYPE; int my_index = -1; jet.getLeadClusterTypeAndIndex(my_type, my_index); double clusterLength = -1.; double clusterVolume = -1.; if ( my_type == NO_TYPE ) continue; if ( my_type == HGCEE ){ HGCEECluster c(*hgceeClusters, my_index); clusterLength = c.getLength(); clusterVolume = c.getVolume(); } else if ( my_type == HGCHEF ){ HGCHEFCluster c(*hgchefClusters, my_index); clusterLength = c.getLength(); clusterVolume = c.getVolume(); } else { HGCHEBCluster c(*hgchebClusters, my_index); clusterLength = c.getLength(); clusterVolume = c.getVolume(); } double core_over_total_pt = -1.; double lead_core_jet_dr = -1.; double n_core_jets = matched_core_jets -> GetSize(); if ( n_core_jets > 0 ){ PFCoreJet lead_core_jet = matched_core_jets -> GetLeadPtObject<PFCoreJet> (); double core_pt = lead_core_jet.Pt(); core_over_total_pt = core_pt / jet.Pt(); lead_core_jet_dr = jet.DeltaR( &lead_core_jet ); } int flavor = getFlavor ( jet , partons ); if ( flavor == -1 ) continue; bool isQuarkJet ( flavor == 1 ); bool isGluonJet ( flavor == 0 ); likelihood_variables.clear(); double weighted_depth = jet.getWeightedDepth(); double weighted_depth_noEE = jet.getWeightedDepthNoEE(); double profile[n_radii]; jet.getProfile(n_radii, radii, profile); double profile50 = jet.getProfileRadius(n_radii, radii, profile, 0.5); double profile90 = jet.getProfileRadius(n_radii, radii, profile, 0.9); double profile95 = jet.getProfileRadius(n_radii, radii, profile, 0.95); double profile99 = jet.getProfileRadius(n_radii, radii, profile, 0.99); likelihood_variables.push_back ( jet.TrimmedNSubjets(index) ); likelihood_variables.push_back ( jet.getWidth() ); likelihood_variables.push_back ( jet.getNPFCandidates() ); likelihood_variables.push_back ( jet.getPTD() ); likelihood_variables.push_back ( jet.NSubJettiness() ); likelihood_variables.push_back ( jet.TrimmedMass(index) * 1000. ); likelihood_variables.push_back ( profile50 ); likelihood_variables.push_back ( core_over_total_pt ); likelihood_variables.push_back ( lead_core_jet_dr ); double ee_energy = jet.getEEEnergy(); double ee015_energy = jet.getEEEnergy(0, 15); double ee1631_energy = jet.getEEEnergy(16, 31); double hef_energy = jet.getHEFEnergy(); double heb_energy = jet.getHEBEnergy(); double all_energy = ee_energy + hef_energy + heb_energy; double hef11_energy = jet.getHEFEnergy(1, 1); double hef22_energy = jet.getHEFEnergy(2, 2); double hef34_energy = jet.getHEFEnergy(3, 4); double hef56_energy = jet.getHEFEnergy(5, 6); double hef712_energy = jet.getHEFEnergy(7,12); double likelihood = l.getLikelihood ( likelihood_variables ); if ( isQuarkJet ){ quark_th1[0] -> Fill ( jet.NSubJettiness() ); quark_th1[1] -> Fill ( jet.TrimmedMass(index) * 1000. ); quark_th1[2] -> Fill ( jet.TrimmedNSubjets(index) ); quark_th1[3] -> Fill ( jet.getNPFCandidates() ); quark_th1[4] -> Fill ( jet.getWidth() ); quark_th1[5] -> Fill ( jet.getChargedWidth() ); quark_th1[6] -> Fill ( jet.getNeutralWidth() ); quark_th1[7] -> Fill ( weighted_depth ); quark_th1[8] -> Fill ( weighted_depth_noEE ); quark_th1[9] -> Fill ( jet.getPTD() ); quark_th1[10] -> Fill ( likelihood ); quark_th1[11] -> Fill ( ee_energy / all_energy ); quark_th1[12] -> Fill ( ee015_energy / all_energy ); quark_th1[13] -> Fill ( ee1631_energy / all_energy ); quark_th1[14]-> Fill ( heb_energy / all_energy ); quark_th1[15]-> Fill ( hef_energy / all_energy ); quark_th1[16]-> Fill ( hef11_energy / all_energy ); quark_th1[17]-> Fill ( hef22_energy / all_energy ); quark_th1[18]-> Fill ( hef34_energy / all_energy ); quark_th1[19]-> Fill ( hef56_energy / all_energy ); quark_th1[20]-> Fill ( hef712_energy / all_energy ); for (int i_radius = 0; i_radius < n_radii; ++i_radius){ quark_th1[21] -> Fill(radii[i_radius], profile[i_radius]); } quark_th1[22] -> Fill ( profile50 ); quark_th1[23] -> Fill ( profile90 ); quark_th1[24] -> Fill ( profile95 ); quark_th1[25] -> Fill ( profile99 ); quark_th1[26] -> Fill ( n_core_jets ); quark_th1[27] -> Fill ( lead_core_jet_dr ); quark_th1[28] -> Fill ( core_over_total_pt ); quark_th1[29] -> Fill ( clusterVolume ); quark_th1[30] -> Fill ( clusterLength ); quark_th2[0] -> Fill ( jet.Pt(), weighted_depth ); quark_th2[1] -> Fill ( jet.Pt(), jet.getMaxRHDepth()); quark_th2[2] -> Fill ( jet.getNPFCandidates(), jet.TrimmedNSubjets(index) ); } if ( isGluonJet ){ gluon_th1[0] -> Fill ( jet.NSubJettiness() ); gluon_th1[1] -> Fill ( jet.TrimmedMass(index) * 1000. ); gluon_th1[2] -> Fill ( jet.TrimmedNSubjets(index) ); gluon_th1[3] -> Fill ( jet.getNPFCandidates() ); gluon_th1[4] -> Fill ( jet.getWidth() ); gluon_th1[5] -> Fill ( jet.getChargedWidth() ); gluon_th1[6] -> Fill ( jet.getNeutralWidth() ); gluon_th1[7] -> Fill ( weighted_depth ); gluon_th1[8] -> Fill ( weighted_depth_noEE ); gluon_th1[9] -> Fill ( jet.getPTD() ); gluon_th1[10] -> Fill ( likelihood ); gluon_th1[11] -> Fill ( ee_energy / all_energy ); gluon_th1[12] -> Fill ( ee015_energy / all_energy ); gluon_th1[13] -> Fill ( ee1631_energy / all_energy ); gluon_th1[14]-> Fill ( heb_energy / all_energy ); gluon_th1[15]-> Fill ( hef_energy / all_energy ); gluon_th1[16]-> Fill ( hef11_energy / all_energy ); gluon_th1[17]-> Fill ( hef22_energy / all_energy ); gluon_th1[18]-> Fill ( hef34_energy / all_energy ); gluon_th1[19]-> Fill ( hef56_energy / all_energy ); gluon_th1[20]-> Fill ( hef712_energy / all_energy ); for (int i_radius = 0; i_radius < n_radii; ++i_radius){ gluon_th1[21] -> Fill(radii[i_radius], profile[i_radius]); } gluon_th1[22] -> Fill ( profile50 ); gluon_th1[23] -> Fill ( profile90 ); gluon_th1[24] -> Fill ( profile95 ); gluon_th1[25] -> Fill ( profile99 ); gluon_th1[26] -> Fill ( n_core_jets ); gluon_th1[27] -> Fill ( lead_core_jet_dr ); gluon_th1[28] -> Fill ( core_over_total_pt ); gluon_th1[29] -> Fill ( clusterVolume ); gluon_th1[30] -> Fill ( clusterLength ); gluon_th2[0] -> Fill ( jet.Pt(), weighted_depth ); gluon_th2[1] -> Fill ( jet.Pt(), jet.getMaxRHDepth()); gluon_th2[2] -> Fill ( jet.getNPFCandidates(), jet.TrimmedNSubjets(index) ); } } }
std::vector<Jet*> TowerJetInput::get_input(PHCompositeNode *topNode) { if (_verbosity > 0) cout << "TowerJetInput::process_event -- entered" << endl; GlobalVertexMap* vertexmap = findNode::getClass<GlobalVertexMap>(topNode,"GlobalVertexMap"); if (!vertexmap) { cout <<"TowerJetInput::get_input - Fatal Error - GlobalVertexMap node is missing. Please turn on the do_global flag in the main macro in order to reconstruct the global vertex."<<endl; assert(vertexmap); // force quit return std::vector<Jet*>(); } RawTowerContainer *towers = NULL; RawTowerGeomContainer *geom = NULL; if (_input == Jet::CEMC_TOWER) { towers = findNode::getClass<RawTowerContainer>(topNode,"TOWER_CALIB_CEMC"); geom = findNode::getClass<RawTowerGeomContainer>(topNode,"TOWERGEOM_CEMC"); if (!towers||!geom) { return std::vector<Jet*>(); } } else if (_input == Jet::HCALIN_TOWER) { towers = findNode::getClass<RawTowerContainer>(topNode,"TOWER_CALIB_HCALIN"); geom = findNode::getClass<RawTowerGeomContainer>(topNode,"TOWERGEOM_HCALIN"); if (!towers||!geom) { return std::vector<Jet*>(); } } else if (_input == Jet::HCALOUT_TOWER) { towers = findNode::getClass<RawTowerContainer>(topNode,"TOWER_CALIB_HCALOUT"); geom = findNode::getClass<RawTowerGeomContainer>(topNode,"TOWERGEOM_HCALOUT"); if (!towers||!geom) { return std::vector<Jet*>(); } } else if (_input == Jet::FEMC_TOWER) { towers = findNode::getClass<RawTowerContainer>(topNode,"TOWER_CALIB_FEMC"); geom = findNode::getClass<RawTowerGeomContainer>(topNode,"TOWERGEOM_FEMC"); if (!towers||!geom) { return std::vector<Jet*>(); } } else if (_input == Jet::FHCAL_TOWER) { towers = findNode::getClass<RawTowerContainer>(topNode,"TOWER_CALIB_FHCAL"); geom = findNode::getClass<RawTowerGeomContainer>(topNode,"TOWERGEOM_FHCAL"); if (!towers||!geom) { return std::vector<Jet*>(); } } else if (_input == Jet::CEMC_TOWER_SUB1) { towers = findNode::getClass<RawTowerContainer>(topNode,"TOWER_CALIB_CEMC_RETOWER_SUB1"); geom = findNode::getClass<RawTowerGeomContainer>(topNode,"TOWERGEOM_HCALIN"); if (!towers||!geom) { return std::vector<Jet*>(); } } else if (_input == Jet::HCALIN_TOWER_SUB1) { towers = findNode::getClass<RawTowerContainer>(topNode,"TOWER_CALIB_HCALIN_SUB1"); geom = findNode::getClass<RawTowerGeomContainer>(topNode,"TOWERGEOM_HCALIN"); if (!towers||!geom) { return std::vector<Jet*>(); } } else if (_input == Jet::HCALOUT_TOWER_SUB1) { towers = findNode::getClass<RawTowerContainer>(topNode,"TOWER_CALIB_HCALOUT_SUB1"); geom = findNode::getClass<RawTowerGeomContainer>(topNode,"TOWERGEOM_HCALOUT"); if (!towers||!geom) { return std::vector<Jet*>(); } } else { return std::vector<Jet*>(); } // first grab the event vertex or bail GlobalVertex* vtx = vertexmap->begin()->second; float vtxz = NAN; if (vtx) vtxz = vtx->get_z(); else return std::vector<Jet*>(); if (isnan(vtxz)) { static bool once = true; if (once) { once = false; cout <<"TowerJetInput::get_input - WARNING - vertex is NAN. Drop all tower inputs (further NAN-vertex warning will be suppressed)."<<endl; } return std::vector<Jet*>(); } std::vector<Jet*> pseudojets; RawTowerContainer::ConstRange begin_end = towers->getTowers(); RawTowerContainer::ConstIterator rtiter; for (rtiter = begin_end.first; rtiter != begin_end.second; ++rtiter) { RawTower *tower = rtiter->second; RawTowerGeom * tower_geom = geom->get_tower_geometry(tower -> get_key()); assert(tower_geom); double r = tower_geom->get_center_radius(); double phi = atan2(tower_geom->get_center_y(), tower_geom->get_center_x()); double z0 = tower_geom->get_center_z(); double z = z0 - vtxz; double eta = asinh(z/r); // eta after shift from vertex double pt = tower->get_energy() / cosh(eta); double px = pt * cos(phi); double py = pt * sin(phi); double pz = pt * sinh(eta); Jet *jet = new JetV1(); jet->set_px(px); jet->set_py(py); jet->set_pz(pz); jet->set_e(tower->get_energy()); jet->insert_comp(_input,tower->get_id()); pseudojets.push_back(jet); } if (_verbosity > 0) cout << "TowerJetInput::process_event -- exited" << endl; return pseudojets; }