本文整理汇总了C++中TChain::SetEventList方法的典型用法代码示例。如果您正苦于以下问题:C++ TChain::SetEventList方法的具体用法?C++ TChain::SetEventList怎么用?C++ TChain::SetEventList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TChain
的用法示例。
在下文中一共展示了TChain::SetEventList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FillHists
void FillHists(rt::TH1Container& hc, TChain& chain, const std::string& sample_name, long num_events = std::numeric_limits<long>::max())
{
// number of events
num_events = (chain.GetEntries() < num_events ? chain.GetEntries() : num_events);
std::cout << "Beginning " << sample_name << " on " << num_events << " of " << chain.GetEntries() << " events..." << std::endl;
// scale the # of events
const float nevts_aod = chain.GetMaximum("evt_nEvts"); // # files in AOD
const float nevts_file = chain.GetEntries(); // # files in this sample
const float nevts_scale = nevts_aod/nevts_file; // scale factor to "fix" evt_scale1fb since we are using a subset of the data
// lumi
static const float lumi = 0.082; //fb^-1
// efficiency scale
float eff_scale = 1.0;
if (sample_name == "data" ) {eff_scale = s_SDEfficiency[ 0];}
if (sample_name == "dyll" ) {eff_scale = s_SDEfficiency[ 1];}
if (sample_name == "wjets" ) {eff_scale = s_SDEfficiency[ 2];}
if (sample_name == "ttdil" ) {eff_scale = s_SDEfficiency[ 3];}
if (sample_name == "ttslq" ) {eff_scale = s_SDEfficiency[ 4];}
if (sample_name == "tthad" ) {eff_scale = s_SDEfficiency[ 5];}
if (sample_name == "qcd" ) {eff_scale = s_SDEfficiency[ 6];}
if (sample_name == "ww" ) {eff_scale = s_SDEfficiency[ 7];}
if (sample_name == "wz2l2q" ) {eff_scale = s_SDEfficiency[ 8];}
if (sample_name == "wz3l" ) {eff_scale = s_SDEfficiency[ 9];}
if (sample_name == "zz2l2q" ) {eff_scale = s_SDEfficiency[10];}
if (sample_name == "zz2l2nu") {eff_scale = s_SDEfficiency[11];}
if (sample_name == "zz4l" ) {eff_scale = s_SDEfficiency[12];}
// overall scale
const float scale = lumi * eff_scale * nevts_scale;
std::cout << "scale factor = " << Form("%f * %f * %f = %f", lumi, eff_scale, nevts_scale, scale) << std::endl;
// book hists
hc.Add(new TH1F(Form("h_count_mm_%s", sample_name.c_str()), Form("Event ee count (%s)" , sample_name.c_str()), 3 , -0.5, 2.5));
hc.Add(new TH1F(Form("h_count_ee_%s", sample_name.c_str()), Form("Event #mu#mu count (%s)" , sample_name.c_str()), 3 , -0.5, 2.5));
hc.Add(new TH1F(Form("h_mee_%s" , sample_name.c_str()), Form("Dimuon Electron (%s);m_{ee}(GeV);# Events Expected", sample_name.c_str()), 60, 60, 120));
hc.Add(new TH1F(Form("h_mmm_%s" , sample_name.c_str()), Form("Dimuon Mass (%s);m_{#mu#mu}(GeV);# Events Expected", sample_name.c_str()), 60, 60, 120));
hc.Sumw2();
// alias for dilepton mass
chain.SetAlias("mass_mm_px", "Sum$(abs(genps_id)==13 && genps_status==3 ? genps_p4.Px() : 0.0)");
chain.SetAlias("mass_mm_py", "Sum$(abs(genps_id)==13 && genps_status==3 ? genps_p4.Py() : 0.0)");
chain.SetAlias("mass_mm_pz", "Sum$(abs(genps_id)==13 && genps_status==3 ? genps_p4.Pz() : 0.0)");
chain.SetAlias("mass_mm_e" , "Sum$(abs(genps_id)==13 && genps_status==3 ? genps_p4.E() : 0.0)");
chain.SetAlias("mass_mm" , "sqrt(mass_mm_e*mass_mm_e - mass_mm_px*mass_mm_px - mass_mm_py*mass_mm_py - mass_mm_pz*mass_mm_pz)");
chain.SetAlias("mass_ee_px", "Sum$(abs(genps_id)==11 && genps_status==3 ? genps_p4.Px() : 0.0)");
chain.SetAlias("mass_ee_py", "Sum$(abs(genps_id)==11 && genps_status==3 ? genps_p4.Py() : 0.0)");
chain.SetAlias("mass_ee_pz", "Sum$(abs(genps_id)==11 && genps_status==3 ? genps_p4.Pz() : 0.0)");
chain.SetAlias("mass_ee_e" , "Sum$(abs(genps_id)==11 && genps_status==3 ? genps_p4.E() : 0.0)");
chain.SetAlias("mass_ee" , "sqrt(mass_ee_e*mass_ee_e - mass_ee_px*mass_ee_px - mass_ee_py*mass_ee_py - mass_ee_pz*mass_ee_pz)");
// fill hist
hc.SetDirectory(gDirectory);
const TCut selection_ee = Form("%1.4f*evt_scale1fb*(Sum$(genps_status==3 && genps_id==11)>=1 && Sum$(genps_status==3 && genps_id==-11)>=1)", scale);
chain.Draw(">>event_list_ee", selection_ee, "goff", num_events);
TEventList * const event_list_ee = dynamic_cast<TEventList*>(gDirectory->Get("event_list_ee"));
chain.SetEventList(event_list_ee);
std::cout << "filling ee hists..." << std::endl;
chain.Draw(Form("1>>h_count_ee_%s" , sample_name.c_str()), selection_ee, "goff", num_events);
chain.Draw(Form("mass_ee>>h_mee_%s", sample_name.c_str()), selection_ee, "goff", num_events);
const TCut selection_mm = Form("%1.4f*evt_scale1fb*(Sum$(genps_status==3 && genps_id==13)>=1 && Sum$(genps_status==3 && genps_id==-13)>=1)", scale);
chain.SetEventList(NULL);
chain.Draw(">>event_list_mm", selection_mm, "goff", num_events);
TEventList * const event_list_mm = dynamic_cast<TEventList*>(gDirectory->Get("event_list_mm"));
chain.SetEventList(event_list_mm);
std::cout << "filling mm hists..." << std::endl;
chain.Draw(Form("1>>h_count_mm_%s" , sample_name.c_str()), selection_mm, "goff", num_events);
chain.Draw(Form("mass_mm>>h_mmm_%s", sample_name.c_str()), selection_mm, "goff", num_events);
hc.SetDirectory(NULL);
std::cout << "Complete " << sample_name << ": ";
std::cout << "mm count = " << rt::Integral(hc["h_count_mm_"+sample_name]) << " (" << hc["h_count_mm_"+sample_name]->GetEntries() << ") : ";
std::cout << "ee count = " << rt::Integral(hc["h_count_ee_"+sample_name]) << " (" << hc["h_count_ee_"+sample_name]->GetEntries() << ")\n" << std::endl;
// done
return;
}