本文整理汇总了C++中Jet::mutable_physics_object方法的典型用法代码示例。如果您正苦于以下问题:C++ Jet::mutable_physics_object方法的具体用法?C++ Jet::mutable_physics_object怎么用?C++ Jet::mutable_physics_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jet
的用法示例。
在下文中一共展示了Jet::mutable_physics_object方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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();
//.........这里部分代码省略.........